Part Number Hot Search : 
TB62716F M74HC SV40114 6030554 5KE33A BAV70 2SC1213D TC144E
Product Description
Full Text Search
 

To Download 68HC912DG128CPV8 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  motorola.com/semiconductors m68hc12 microcontrollers mc68hc912dg128/d rev. 3, 10/2002 mc68hc912dg128 technical data f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola 3 mc68hc912dg128 technical data ? rev 3.0 motorola reserves the right to make changes without further notice to any products herein. motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. "typical" parameters which may be provided in motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. all operating parameters, including "typicals" must be validated for each customer application by customer?s technical experts. motorola does not convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola, inc. is an equal opportunity/affirmative action employer. motorola and are registered trademarks of motorola, inc. digitaldna is a trademark of motorola, inc. ? motorola, inc., 2002 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
technical data mc68hc912dg128 ? rev 3.0 4 motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola list of paragraphs 5 technical data ? mc68hc912dg128 list of paragraphs list of paragraphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 table of contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 list of figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 list of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 section 1. general description . . . . . . . . . . . . . . . . . . . . 23 section 2. central processing unit . . . . . . . . . . . . . . . . . 29 section 3. pinout and signal descriptions . . . . . . . . . . . 37 section 4. registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 section 5. operating modes . . . . . . . . . . . . . . . . . . . . . . . 75 section 6. bus control and input/output . . . . . . . . . . . . 95 section 7. flash memory . . . . . . . . . . . . . . . . . . . . . . . . 107 section 8. eeprom memory . . . . . . . . . . . . . . . . . . . . . 125 section 9. resets and interrupts . . . . . . . . . . . . . . . . . . 133 section 10. i/o ports with key wake-up . . . . . . . . . . . . 147 section 11. clock functions . . . . . . . . . . . . . . . . . . . . . 155 section 12. pulse width modulator . . . . . . . . . . . . . . . . 191 section 13. enhanced capture timer . . . . . . . . . . . . . . 207 section 14. multiple serial interface . . . . . . . . . . . . . . . 249 section 15. inter-ic bus . . . . . . . . . . . . . . . . . . . . . . . . . 273 section 16. analog-to-digital converter . . . . . . . . . . . . 297 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of paragraphs technical data mc68hc912dg128 ? rev 3.0 6 list of paragraphs motorola section 17. mscan controller. . . . . . . . . . . . . . . . . . . . 311 section 18. development support. . . . . . . . . . . . . . . . . 355 section 19. electrical specifications. . . . . . . . . . . . . . . 385 section 20. appendix: cgm practical aspects . . . . . . 407 section 21. appendix: mc68hc912dg128a flash . . . 419 section 22. appendix: mc68hc912dg128a eeprom 427 section 23. revision history . . . . . . . . . . . . . . . . . . . . . 439 glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola table of contents 7 technical data ? mc68hc912dg128 table of contents list of paragraphs table of contents list of figures list of tables section 1. general description 1.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 1.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 1.4 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.5 mc68hc912dg128 block diagram . . . . . . . . . . . . . . . . . . . . . 28 section 2. central processing unit 2.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 2.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.3 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 2.4 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 2.6 indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . .34 2.7 opcodes and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents technical data mc68hc912dg128 ? rev 3.0 8 table of contents motorola section 3. pinout and signal descriptions 3.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 3.2 pin assignments in 112-pin qfp . . . . . . . . . . . . . . . . . . . . . . . 37 3.3 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 3.4 signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.5 port signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 section 4. registers 4.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 4.2 register block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 section 5. operating modes 5.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 5.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.3 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 5.4 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.5 internal resource mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.6 memory maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 section 6. bus control and input/output 6.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 6.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.3 detecting access type from external signals . . . . . . . . . . . . .95 6.4 registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 section 7. flash memory 7.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 7.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents mc68hc912dg128 ? rev 3.0 technical data motorola table of contents 9 7.3 future flash eeprom support . . . . . . . . . . . . . . . . . . . . . . . 108 7.4 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 7.5 flash eeprom control block . . . . . . . . . . . . . . . . . . . . . . . . 109 7.6 flash eeprom arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.7 flash eeprom registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 7.8 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115 7.9 programming the flash eeprom . . . . . . . . . . . . . . . . . . . . . 118 7.10 erasing the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . .120 7.11 program/erase protection interlocks . . . . . . . . . . . . . . . . . . .122 7.12 stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 7.13 test mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 section 8. eeprom memory 8.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 8.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 8.3 future eeprom support . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 8.4 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . . 127 8.5 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 128 section 9. resets and interrupts 9.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 9.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 9.3 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 9.4 latching of interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 9.5 interrupt control and priority registers . . . . . . . . . . . . . . . . . 137 9.6 interrupt test registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.7 resets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents technical data mc68hc912dg128 ? rev 3.0 10 table of contents motorola 9.8 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 9.9 register stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 9.10 important user information . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 section 10. i/o ports with key wake-up 10.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 10.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 10.3 key wake-up and port registers . . . . . . . . . . . . . . . . . . . . . .148 10.4 key wake-up input filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 section 11. clock functions 11.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 11.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 11.3 clock sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 11.4 phase-locked loop (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . .157 11.5 acquisition and tracking modes. . . . . . . . . . . . . . . . . . . . . . .159 11.6 limp-home and fast stop recovery modes . . . . . . . . . . . . 161 11.7 system clock frequency formulas . . . . . . . . . . . . . . . . . . . . . 179 11.8 clock divider chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 11.9 computer operating properly (cop) . . . . . . . . . . . . . . . . . . .184 11.10 real-time interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11.11 clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11.12 clock function registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 section 12. pulse width modulator 12.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 12.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents mc68hc912dg128 ? rev 3.0 technical data motorola table of contents 11 12.3 pwm register description . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 12.4 pwm boundary cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 section 13. enhanced capture timer 13.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 13.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 13.3 enhanced capture timer modes of operation . . . . . . . . . . . . 214 13.4 timer registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 13.5 timer and modulus counter operation in different modes . .247 section 14. multiple serial interface 14.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 14.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 14.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 14.4 serial communication interface (sci) . . . . . . . . . . . . . . . . . . 250 14.5 serial peripheral interface (spi) . . . . . . . . . . . . . . . . . . . . . . . 262 14.6 port s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 section 15. inter-ic bus 15.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 15.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 15.3 iic features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 15.4 iic system configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 15.5 iic protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 15.6 iic register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 15.7 iic programming examples . . . . . . . . . . . . . . . . . . . . . . . . . .290 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents technical data mc68hc912dg128 ? rev 3.0 12 table of contents motorola section 16. analog-to-digital converter 16.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 16.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 16.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 16.4 atd registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 16.5 atd mode operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 section 17. mscan controller 17.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 17.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 17.3 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 17.4 message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313 17.5 identifier acceptance filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 17.6 interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 17.7 protocol violation protection. . . . . . . . . . . . . . . . . . . . . . . . . . 324 17.8 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 17.9 timer link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 17.10 clock system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 17.11 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 17.12 programmer ? s model of message storage . . . . . . . . . . . . . . .332 17.13 programmer ? s model of control registers . . . . . . . . . . . . . . . 338 section 18. development support 18.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 18.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 18.3 instruction queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 18.4 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents mc68hc912dg128 ? rev 3.0 technical data motorola table of contents 13 18.5 breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 18.6 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 section 19. electrical specifications 19.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 19.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 19.3 tables of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 section 20. appendix: cgm practical aspects 20.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 20.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 20.3 a few hints for the cgm crystal oscillator application. . . . 407 20.4 practical aspects for the pll usage . . . . . . . . . . . . . . . . . . 410 20.5 printed circuit board guidelines. . . . . . . . . . . . . . . . . . . . . . . 415 section 21. appendix: mc68hc912dg128a flash 21.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 21.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 21.3 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 21.4 flash eeprom control block . . . . . . . . . . . . . . . . . . . . . . . . 420 21.5 flash eeprom arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 21.6 flash eeprom registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 21.7 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423 21.8 programming the flash eeprom . . . . . . . . . . . . . . . . . . . . . 424 21.9 erasing the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . 425 21.10 stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
table of contents technical data mc68hc912dg128 ? rev 3.0 14 table of contents motorola section 22. appendix: mc68hc912dg128a eeprom 22.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 22.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 22.3 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . . 428 22.4 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 430 22.5 program/erase operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 22.6 shadow word mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . .436 22.7 programming eedivh and eedivl registers. . . . . . . . . . . . 437 section 23. revision history glossary f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola list of figures 15 technical data ? mc68hc912dg128 list of figures figure title page 2-1 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 3-1 mc68hc912dg128 pin assignments in 112-pin qfp. . . . . . . 38 3-2 112-pin qfp mechanical dimensions (case no987) . . . . . . . .39 3-3 pll loop filter connections . . . . . . . . . . . . . . . . . . . . . . . . . .41 3-4 common crystal connections . . . . . . . . . . . . . . . . . . . . . . . . . 43 3-5 external oscillator connections . . . . . . . . . . . . . . . . . . . . . . . . 43 5-1 memory map after reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 5-2 memory paging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 6-1 access type vsbus control pins . . . . . . . . . . . . . . . . . . . . . . . 96 7-1 program sequence flow . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 7-2 erase sequence flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121 10-1 stop key wake-up filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 11-1 internal clock relationships . . . . . . . . . . . . . . . . . . . . . . . . . . 157 11-2 pll functional diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 11-3 clock loss during normal operation . . . . . . . . . . . . . . . . . . .162 11-4 no clock at power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . 164 11-5 stop exit and fast stop recovery . . . . . . . . . . . . . . . . . . . 167 11-6 clock generation chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 11-7 clock chain for sci0, sci1, rti, cop. . . . . . . . . . . . . . . . . . 181 11-8 clock chain for ect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 11-9 clock chain for mscan, spi, atd0, atd1 and bdm . . . . . . 183 12-1 block diagram of pwm left-aligned output channel . . . . . . 192 12-2 block diagram of pwm center-aligned output channel . . . . 193 12-3 pwm clock sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 13-1 timer block diagram in latch mode. . . . . . . . . . . . . . . . . . . . 209 13-2 timer block diagram in queue mode. . . . . . . . . . . . . . . . . . . 210 13-3 8-bit pulse accumulators block diagram . . . . . . . . . . . . . . . . 211 13-4 16-bit pulse accumulators block diagram . . . . . . . . . . . . . . .212 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of figures technical data mc68hc912dg128 ? rev 3.0 16 list of figures motorola 13-5 block diagram for port7 with output compare / pulse accumulator a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 13-6 c3f-c0f interrupt flag setting . . . . . . . . . . . . . . . . . . . . . . . 213 14-1 multiple serial interface block diagram . . . . . . . . . . . . . . . . . 250 14-2 serial communications interface block diagram . . . . . . . . . . 251 14-3 serial peripheral interface block diagram . . . . . . . . . . . . . . . 263 14-4 spi clock format 0 (cpha = 0) . . . . . . . . . . . . . . . . . . . . . . . 264 14-5 spi clock format 1 (cpha = 1) . . . . . . . . . . . . . . . . . . . . . . . 265 14-6 normal mode and bidirectional mode. . . . . . . . . . . . . . . . . . . 266 15-1 iic block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 15-2 iic transmission signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 15-3 iic clock synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 15-4 flow-chart of typical iic interrupt routine . . . . . . . . . . . . . . 295 16-1 analog-to-digital converter block diagram . . . . . . . . . . . . . . 298 17-1 the can system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 17-2 user model for message buffer organization. . . . . . . . . . . . . 316 17-3 32-bit maskable identifier acceptance filters . . . . . . . . . . . . . 320 17-4 16-bit maskable acceptance filters . . . . . . . . . . . . . . . . . . . . 320 17-5 8-bit maskable acceptance filters . . . . . . . . . . . . . . . . . . . . . 321 17-6 sleep request / acknowledge cycle . . . . . . . . . . . . . . . . . . 327 17-7 clocking scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 17-8 segments within the bit time . . . . . . . . . . . . . . . . . . . . . . . . . 331 17-9 can standard compliant bit time segment settings . . . . . . 331 17-10 mscan12 memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332 17-11 message buffer organization . . . . . . . . . . . . . . . . . . . . . . . . .333 17-12 receive/transmit message buffer extended identifier. . . . . . 334 17-13 standard identifier mapping . . . . . . . . . . . . . . . . . . . . . . . . . .335 17-14 identifier acceptance registers (1st bank) . . . . . . . . . . . . . . .351 17-15 identifier acceptance registers (2nd bank) . . . . . . . . . . . . . . 351 17-16 identifier mask registers (1st bank) . . . . . . . . . . . . . . . . . . . . 352 17-17 identifier mask registers (2nd bank) . . . . . . . . . . . . . . . . . . .352 18-1 bdm host to target serial bit timing. . . . . . . . . . . . . . . . . . . 359 18-2 bdm target to host serial bit timing (logic 1) . . . . . . . . . . . 359 18-3 bdm target to host serial bit timing (logic 0) . . . . . . . . . . . 360 19-1 v fp conditioning circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . .393 19-2 v fp operating range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 19-3 timer inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 19-4 por and external reset timing diagram . . . . . . . . . . . . . . . 396 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of figures mc68hc912dg128 ? rev 3.0 technical data motorola list of figures 17 19-5 stop recovery timing diagram . . . . . . . . . . . . . . . . . . . . . .397 19-6 wait recovery timing diagram . . . . . . . . . . . . . . . . . . . . . . 398 19-7 interrupt timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 19-8 port read timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 19-9 port write timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 19-10 multiplexed expansion bus timing diagram . . . . . . . . . . . . . 402 a) spi master timing (cpha = 0) . . . . . . . . . . . . . . . . . . . . . 404 b) spi master timing (cpha = 1) . . . . . . . . . . . . . . . . . . . . . 404 19-11 spi timing diagram (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . 404 19-11 a) spi slave timing (cpha = 0) . . . . . . . . . . . . . . . . . . . . . . 405 19-11 b) spi slave timing (cpha = 1) . . . . . . . . . . . . . . . . . . . . . . 405 19-12 spi timing diagram (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . 405 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of figures technical data mc68hc912dg128 ? rev 3.0 18 list of figures motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola list of tables 19 technical data ? mc68hc912dg128 list of tables table title page 1-1 device ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1-2 development tools ordering information. . . . . . . . . . . . . . . . . 27 2-1 m68hc12 addressing mode summary . . . . . . . . . . . . . . . . . . 32 2-2 m68hc12 addressing mode summary . . . . . . . . . . . . . . . . . . 33 2-3 summary of indexed operations . . . . . . . . . . . . . . . . . . . . . . . 34 3-1 power and ground connection summary . . . . . . . . . . . . . . . .42 3-2 signal description summary . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3-3 port description summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3-4 port pull-up, pull-down and reduced drive summary . . . . . .60 4-1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5-1 mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 5-2 mapping precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 5-3 program space page index . . . . . . . . . . . . . . . . . . . . . . . . . . .86 5-4 flash register space page index. . . . . . . . . . . . . . . . . . . . . . .86 5-5 test mode program space page index. . . . . . . . . . . . . . . . . . . 87 5-6 rfstr stretch bit definition . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5-7 exstr stretch bit definition . . . . . . . . . . . . . . . . . . . . . . . . . . 91 7-1 effects of enpe, lat and eras on array reads . . . . . . . . .114 8-1 2k byte eeprom block protection . . . . . . . . . . . . . . . . . . . . 129 8-2 erase selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 9-1 interrupt vector map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 9-2 stacking order on entry to interrupts . . . . . . . . . . . . . . . . . . . 144 11-1 summary of stop mode exit conditions. . . . . . . . . . . . . . . . 172 11-2 summary of pseudo stop mode exit conditions . . . . . . . . . 173 11-3 clock monitor time-outs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 11-4 real time interrupt rates. . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 11-5 cop watchdog rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 12-1 clock a and clock b prescaler. . . . . . . . . . . . . . . . . . . . . . . . 196 12-2 pwm left-aligned boundary conditions . . . . . . . . . . . . . . . . 206 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of tables technical data mc68hc912dg128 ? rev 3.0 20 list of tables motorola 12-3 pwm center-aligned boundary conditions . . . . . . . . . . . . . . 206 13-1 compare result output action . . . . . . . . . . . . . . . . . . . . . . . . 222 13-2 edge detector circuit configuration . . . . . . . . . . . . . . . . . . . . 223 13-3 prescaler selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 14-1 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 14-2 loop mode functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 14-3 ss output selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 14-4 spi clock rate selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 15-1 iic tap and prescale values . . . . . . . . . . . . . . . . . . . . . . . . . 282 15-2 iic divider and sda hold values . . . . . . . . . . . . . . . . . . . . . . 283 16-1 atd response to background debug enable . . . . . . . . . . . . 301 16-2 final sample time selection . . . . . . . . . . . . . . . . . . . . . . . . . 302 16-3 clock prescaler values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 16-4 multichannel mode result register assignment . . . . . . . . . . 305 17-1 mscan12 interrupt vectors . . . . . . . . . . . . . . . . . . . . . . . . . .324 17-2 mscan12 vscpu operating modes . . . . . . . . . . . . . . . . . . . . 325 17-3 data length codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 17-4 synchronization jump width . . . . . . . . . . . . . . . . . . . . . . . . . .341 17-5 baud rate prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 17-6 time segment syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 17-7 time segment values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 17-8 identifier acceptance mode settings . . . . . . . . . . . . . . . . . . .349 17-9 identifier acceptance hit indication . . . . . . . . . . . . . . . . . . . . 349 18-1 ipipe decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 18-2 hardware commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 18-3 bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . . . .363 18-4 bdm registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 18-5 ttago decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 18-6 ttago value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 18-7 instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 18-8 regn decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 18-9 breakpoint mode control . . . . . . . . . . . . . . . . . . . . . . . . . . . .378 18-10 breakpoint address range control . . . . . . . . . . . . . . . . . . . . 379 18-11 breakpoint read/write control . . . . . . . . . . . . . . . . . . . . . . . .380 18-12 tag pin function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 19-1 maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 19-2 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 19-3 dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 387 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of tables mc68hc912dg128 ? rev 3.0 technical data motorola list of tables 21 19-4 supply current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 19-5 atd dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . 389 19-6 analog converter characteristics (operating) . . . . . . . . . . . .390 19-7 atd ac characteristics (operating). . . . . . . . . . . . . . . . . . . . 391 19-8 atd maximum ratings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 19-9 eeprom characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 19-10 flash eeprom characteristics . . . . . . . . . . . . . . . . . . . . . . . 392 19-11 pulse width modulator characteristics. . . . . . . . . . . . . . . . . . 394 19-12 control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 19-13 peripheral port timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400 19-14 multiplexed expansion bus timing. . . . . . . . . . . . . . . . . . . . . 401 19-15 spi timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 19-16 cgm characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 19-17 key wake-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 19-18 mscan12 wake-up time from sleep mode. . . . . . . . . . . . . . 406 20-1 suggested 8mhz synthesis pll filter elements (tracking mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 20-2 suggested 8mhz synthesis pll filter elements (acquisition mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414 22-1 eediv selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 22-2 2k byte eeprom block protection . . . . . . . . . . . . . . . . . . . . 433 22-3 erase selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434 22-4 shadow word mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
list of tables technical data mc68hc912dg128 ? rev 3.0 22 list of tables motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola general description 23 technical data ? mc68hc912dg128 section 1. general description 1.1 contents 1.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 1.4 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.5 mc68hc912dg128 block diagram . . . . . . . . . . . . . . . . . . . . . 28 1.2 introduction the mc68hc912dg128 microcontroller unit (mcu) is a 16-bit device composed of standard on-chip peripherals including a 16-bit central processing unit (cpu12), 128k bytes of flash eeprom, 8k bytes of ram, 2k bytes of eeprom, two asynchronous serial communication interfaces (sci), a serial peripheral interface (spi), an inter-ic interface (i2c), an enhanced capture timer (ect), two 8-channel,10-bit analog-to- digital converters (atd), a four-channel pulse-width modulator (pwm), and two can 2.0 a, b software compatible modules (mscan12). system resource mapping, clock generation, interrupt control and bus interfacing are managed by the lite integration module (lim). the mc68hc912dg128 has full 16-bit data paths throughout, however, the external bus can operate in an 8-bit narrow mode so single 8-bit wide memory can be interfaced for lower cost systems. the inclusion of a pll circuit allows power consumption and performance to be adjusted to suit operational requirements. in addition to the i/o ports available in each module, 16 i/o port pins are available with key-wake-up capability from stop or wait mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
general description technical data mc68hc912dg128 ? rev 3.0 24 general description motorola 1.3 features  16-bit cpu12 ? upward compatible with m68hc11 instruction set ? interrupt stacking and programmer ? s model identical to m68hc11 ? 20-bit alu ? instruction queue ? enhanced indexed addressing  multiplexed bus ? single chip or expanded ? 16 address/16 data wide or 16 address/8 data narrow mode  memory ? 128k byte flash eeprom, made of four 32k byte modules with 8k bytes protected boot section in each module ? 2k byte eeprom ? 8k byte ram, made of two 4k byte modules with vstby in each module.  analog-to-digital converters ? 2 times x 8-channels, 10-bit resolution f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
general description features mc68hc912dg128 ? rev 3.0 technical data motorola general description 25  1m bit per second, can 2.0 a, b software compatible modules, two on the mc68hc912dg128, each with: ? two receive and three transmit buffers ? flexible identifier filter programmable as 2 x 32 bit, 4 x 16 bit or 8x8bit ? four separate interrupt channels for rx, tx, error and wake-up ? low-pass filter wake-up function ? loop-back for self test operation ? programmable link to a timer input capture channel, for time- stamping and network synchronization.  enhanced capture timer (ect) ? 16-bit main counter with 7-bit prescaler ? 8 programmable input capture or output compare channels; 4 of the 8 input captures with buffer ? input capture filters and buffers, three successive captures on four channels, or two captures on four channels with a capture/compare selectable on the remaining four ? four 8-bit or two 16-bit pulse accumulators ? 16-bit modulus down-counter with 4-bit prescaler ? four user-selectable delay counters for signal filtering  4 pwm channels with programmable period and duty cycle ? 8-bit 4-channel or 16-bit 2-channel ? separate control for each pulse width and duty cycle ? center- or left-aligned outputs ? programmable clock select logic with a wide range of frequencies f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
general description technical data mc68hc912dg128 ? rev 3.0 26 general description motorola  serial interfaces ? two asynchronous serial communications interfaces (sci) ? inter ic bus interface (i 2 c) ? synchronous serial peripheral interface (spi)  lim (lite integration module) ? wcr (windowed cop watchdog, real time interrupt, clock monitor) ? roc (reset and clocks) ? mebi (multiplexed external bus interface) ? mbi (internal bus interface and memory map) ? int (interrupt control)  two 8-bit ports with key wake-up interrupt  clock generation ? phase-locked loop clock frequency multiplier ? limp home mode in absence of external clock ? slow mode divider ? low power 0.5 to 16 mhz crystal oscillator reference clock  112-pin tqfp package ? up to 66 general-purpose i/o lines, plus up to 18 input-only lines  8mhz operation at 5v  development support ? single-wire background debug ? mode (bdm) ? on-chip hardware breakpoints f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
general description ordering information mc68hc912dg128 ? rev 3.0 technical data motorola general description 27 1.4 ordering information * important: m temperature operation is available only for single chip modes note: sdbug12 is a p & e micro product. it can be obtained from p & e from their web site (http://www.pemicro.com) for approximately $100. third party tools: http://www.mcu.motsps.com/dev_tools/3rd/index.htm table 1-1. device ordering information package temperature voltage frequency order number range designator 112-pin tqfp single tray 60 pcs 0 to +70 ? 5.5v 8 mhz 68hc912dg128pv8 ? 40 to +85 ? 40 to +105 ? 40 to +125 ????? ? ???? ?? ? ? 5v), m68dil12 (sdil + mcuez + sdbug12) evaluation board evb m68evb912dg128 (evb only) m68kit912dg128 (evb + sdil12) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
general description technical data mc68hc912dg128 ? rev 3.0 28 general description motorola 1.5 mc68hc912dg128 block diagram txcan1 ddrh porth kwh4 kwh3 kwh2 kwh1 kwh0 kwh7 kwh6 kwh5 ph4 ph3 ph2 ph1 ph0 ph7 ph6 ph5 ddrj portj pj4 pj3 pj2 pj1 pj0 pj7 pj6 pj5 kwj4 kwj3 kwj2 kwj1 kwj0 kwj7 kwj6 kwj5 ioc0 ioc1 ioc2 ioc3 ioc4 ioc5 ioc6 ioc7 ddrt port t 128k byte flash eeprom 8k byte ram port e enhanced pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 spi ddrs port s port ad1 pe1 pe2 pe4 pe5 pe6 pe3 pad13 pad14 pad15 pad16 pad17 vdda vssa vrh1 vrl1 pad10 pad11 pad12 reset extal xtal pw0 pw1 pw2 pw3 pwm ddrp port p pp0 pp1 pp2 pp3 vdd ? ? ?? ? ? ? ? ? ? ?? ? ? ? ? ??? ??? ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola central processing unit 29 technical data ? mc68hc912dg128 section 2. central processing unit 2.1 contents 2.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.3 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 2.4 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 2.6 indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . .34 2.7 opcodes and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 2.2 introduction the cpu12 is a high-speed, 16-bit processing unit. it has full 16-bit data paths and wider internal registers (up to 20 bits) for high-speed extended math instructions. the instruction set is a proper superset of the m68hc11instruction set. the cpu12 allows instructions with odd byte counts, including many single-byte instructions. this provides efficient use of rom space. an instruction queue buffers program information so the cpu always has immediate access to at least three bytes of machine code at the start of every instruction. the cpu12 also offers an extensive set of indexed addressing capabilities. 2.3 programming model cpu12 registers are an integral part of the cpu and are not addressed as if they were memory locations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit technical data mc68hc912dg128 ? rev 3.0 30 central processing unit motorola figure 2-1. programming model accumulators a and b are general-purpose 8-bit accumulators used to hold operands and results of arithmetic calculations or data manipulations. some instructions treat the combination of these two 8- bit accumulators as a 16-bit double accumulator (accumulator d). index registers x and y are used for indexed addressing mode. in the indexed addressing mode, the contents of a 16-bit index register are added to 5-bit, 9-bit, or 16-bit constants or the content of an accumulator to form the effective address of the operand to be used in the instruction. stack pointer (sp) points to the last stack location used. the cpu12 supports an automatic program stack that is used to save system context during subroutine calls and interrupts, and can also be used for temporary storage of data. the stack pointer can also be used in all indexed addressing modes. program counter is a 16-bit register that holds the address of the next instruction to be executed. the program counter can be used in all indexed addressing modes except autoincrement/decrement. 7 15 15 15 15 15 d ix iy sp pc ab n sxh i zvc 0 0 0 0 0 0 7 0 condition code register 8-bit accumulators a & b 16-bit double accumulator d index register x index register y stack pointer program counter or f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit data types mc68hc912dg128 ? rev 3.0 technical data motorola central processing unit 31 condition code register (ccr) contains five status indicators, two interrupt masking bits, and a stop disable bit. the five flags are half carry (h), negative (n), zero (z), overflow (v), and carry/borrow (c). the half-carry flag is used only for bcd arithmetic operations. the n, z, v, and c status bits allow for branching based on the results of a previous operation. after a reset, the cpu fetches a vector from the appropriate address and begins executing instructions. the x and i interrupt mask bits are set to mask any interrupt requests. the s bit is also set to inhibit the stop instruction. 2.4 data types the cpu12 supports the following data types:  bit data  8-bit and 16-bit signed and unsigned integers  16-bit unsigned fractions  16-bit addresses a byte is eight bits wide and can be accessed at any byte location. a word is composed of two consecutive bytes with the most significant byte at the lower value address. there are no special requirements for alignment of instructions or operands. 2.5 addressing modes addressing modes determine how the cpu accesses memory locations to be operated upon. the cpu12 includes all of the addressing modes of the m68hc11 cpu as well as several new forms of indexed addressing. table 2-1 is a summary of the available addressing modes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit technical data mc68hc912dg128 ? rev 3.0 32 central processing unit motorola table 2-1. m68hc12 addressing mode summary addressing mode source format abbreviation description inherent inst (no externally supplied operands) inh operands (if any) are in cpu registers immediate inst # opr8i or inst # opr16i imm operand is included in instruction stream 8- or 16-bit size implied by context direct inst opr8a dir operand is the lower 8-bits of an address in the range $0000 ? $00ff extended inst opr16a ext operand is a 16-bit address relative inst rel8 or inst rel16 rel an 8-bit or 16-bit relative offset from the current pc is supplied in the instruction indexed (5-bit offset) inst oprx5 , xysp idx 5-bit signed constant offset from x, y, sp, or pc indexed (auto pre-decrement) inst oprx3 , ? xys idx auto pre-decrement x, y, or sp by 1 ~ 8 indexed (auto pre-increment) inst oprx3 ,+ xys idx auto pre-increment x, y, or sp by 1 ~ 8 indexed (auto post- decrement) inst oprx3 , xys ? idx auto post-decrement x, y, or sp by 1 ~ 8 indexed (auto post-increment) inst oprx3 , xys + idx auto post-increment x, y, or sp by 1 ~ 8 indexed (accumulator offset) inst abd , xysp idx indexed with 8-bit (a or b) or 16-bit (d) accumulator offset from x, y, sp, or pc indexed (9-bit offset) inst oprx9 , xysp idx1 9-bit signed constant offset from x, y, sp, or pc (lower 8-bits of offset in one extension byte) indexed (16-bit offset) inst oprx16 , xysp idx2 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (16-bit offset) inst [ oprx16 , xysp ] [idx2] pointer to operand is found at... 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (d accumulator offset) inst [d, xysp ] [d,idx] pointer to operand is found at... x, y, sp, or pc plus the value in d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit addressing modes mc68hc912dg128 ? rev 3.0 technical data motorola central processing unit 33 table 2-2. m68hc12 addressing mode summary addressing mode source format abbreviation description inherent inst (no externally supplied operands) inh operands (if any) are in cpu registers immediate inst # opr8i or inst # opr16i imm operand is included in instruction stream 8- or 16-bit size implied by context direct inst opr8a dir operand is the lower 8-bits of an address in the range $0000 ? $00ff extended inst opr16a ext operand is a 16-bit address relative inst rel8 or inst rel16 rel an 8-bit or 16-bit relative offset from the current pc is supplied in the instruction indexed (5-bit offset) inst oprx5 , xysp idx 5-bit signed constant offset from x, y, sp, or pc indexed (auto pre-decrement) inst oprx3 , ? xys idx auto pre-decrement x, y, or sp by 1 ~ 8 indexed (auto pre-increment) inst oprx3 ,+ xys idx auto pre-increment x, y, or sp by 1 ~ 8 indexed (auto post-decrement) inst oprx3 , xys ? idx auto post-decrement x, y, or sp by 1 ~ 8 indexed (auto post-increment) inst oprx3 , xys + idx auto post-increment x, y, or sp by 1 ~ 8 indexed (accumulator offset) inst abd , xysp idx indexed with 8-bit (a or b) or 16-bit (d) accumulator offset from x, y, sp, or pc indexed (9-bit offset) inst oprx9 , xysp idx1 9-bit signed constant offset from x, y, sp, or pc (lower 8-bits of offset in one extension byte) indexed (16-bit offset) inst oprx16 , xysp idx2 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (16-bit offset) inst [ oprx16 , xysp ] [idx2] pointer to operand is found at... 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (d accumulator offset) inst [d, xysp ] [d,idx] pointer to operand is found at... x, y, sp, or pc plus the value in d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit technical data mc68hc912dg128 ? rev 3.0 34 central processing unit motorola 2.6 indexed addressing modes the cpu12 indexed modes reduce execution time and eliminate code size penalties for using the y index register. cpu12 indexed addressing uses a postbyte plus zero, one, or two extension bytes after the instruction opcode. the postbyte and extensions do the following tasks:  specify which index register is used.  determine whether a value in an accumulator is used as an offset.  enable automatic pre- or post-increment or decrement  specify use of 5-bit, 9-bit, or 16-bit signed offsets. table 2-3. summary of indexed operations postbyte code (xb) source code syntax comments rr0nnnnn ,r n,r ? n,r 5-bit constant offset n = ? 16 to +15 rr can specify x, y, sp, or pc 111rr0zs n,r ? n,r constant offset (9- or 16-bit signed) z-0 = 9-bit with sign in lsb of postbyte(s) 1 = 16-bit if z = s = 1, 16-bit offset indexed-indirect (see below) rr can specify x, y, sp, or pc 111rr011 [n,r] 16-bit offset indexed-indirect rr can specify x, y, sp, or pc rr1pnnnn n, ? r n,+r n,r ? n,r+ auto pre-decrement/increment or auto post- decrement/increment ; p = pre-(0) or post-(1), n = ? 8 to ? 1, +1 to +8 rr can specify x, y, or sp (pc not a valid choice) 111rr1aa a,r b,r d,r accumulator offset (unsigned 8-bit or 16-bit) aa-00 = a 01 = b 10 = d (16-bit) 11 = see accumulator d offset indexed-indirect rr can specify x, y, sp, or pc 111rr111 [d,r] accumulator d offset indexed-indirect rr can specify x, y, sp, or pc f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit opcodes and operands mc68hc912dg128 ? rev 3.0 technical data motorola central processing unit 35 2.7 opcodes and operands the cpu12 uses 8-bit opcodes. each opcode identifies a particular instruction and associated addressing mode to the cpu. several opcodes are required to provide each instruction with a range of addressing capabilities. only 256 opcodes would be available if the range of values were restricted to the number that can be represented by 8-bit binary numbers. to expand the number of opcodes, a second page is added to the opcode map. opcodes on the second page are preceded by an additional byte with the value $18. to provide additional addressing flexibility, opcodes can also be followed by a postbyte or extension bytes. postbytes implement certain forms of indexed addressing, transfers, exchanges, and loop primitives. extension bytes contain additional program information such as addresses, offsets, and immediate data. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
central processing unit technical data mc68hc912dg128 ? rev 3.0 36 central processing unit motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 37 technical data ? mc68hc912dg128 section 3. pinout and signal descriptions 3.1 contents 3.2 pin assignments in 112-pin qfp . . . . . . . . . . . . . . . . . . . . . . . 37 3.3 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 3.4 signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.5 port signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2 pin assignments in 112-pin qfp the mc68hc912dg128 is available in a 112-pin thin quad flat pack (tqfp). most pins perform two or more functions, as described in the signal descriptions . figure 3-2 shows pin assignments. in expanded narrow modes the lower byte data is multiplexed with higher byte data through pins 57-64. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 38 pinout and signal descriptions motorola figure 3-1 . mc68hc912dg128 pin assignments in 112-pin qfp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 mc68hc912dg128 112tqfp pad17/an17 pad07/an07 pad16/an16 pad06/an06 pad15/an15 pad05/an05 pad14/an14 pad04/an04 pad13/an13 pad03/an03 pad12/an12 pad02/an02 pad11/an11 pad01/an01 pad10/an10 pad00/an00 v rl0 v rh0 v ss v dd pa7/addr15/data15/data7 pa6/addr14/data14/data6 pa5/addr13/data13/data5 pa4/addr12/data12/data4 pa3/addr11/data11/data3 pa2/addr10/data10/data2 pa1/addr9/data9/data1 pa0/addr8/data8/data0 pp3/pw3 pk0/pix0 pk1/pix1 pk2/pix2 pk7/ecs v ddx v ssx rxcan0 txcan0 rxcan1 txcan1 pib4 pib5 pib6/sda pib7/scl v fp * ps7/ss ps6/sck ps5/sdo/mosi ps4/sdi/miso ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 v ssa v rl1 v rh1 v dda pw2/pp2 pw1/pp1 pw0/pp0 ioc0/pt0 ioc1/pt1 ioc2/pt2 ioc3/pt3 kwj7/pj7 kwj6/pj6 kwj5/pj5 kwj4/pj4 v dd pk3 v ss ioc4/pt4 ioc5/pt5 ioc6/pt6 ioc7/pt7 kwj3/pj3 kwj2/pj2 kwj1/pj1 kwj0/pj0 smodn/taghi/ bkgd addr0/data0/pb0 addr1/data1/pb1 addr2/data2/pb2 addr3/data3/pb3 addr4/data4/pb4 addr5/data5/pb5 addr6/data6/pb6 addr7/data7/pb7 kwh7/ph7 kwh6/ph6 kwh5/ph5 kwh4/ph4 dbe/ cal/pe7 modb/ipipe1/pe6 moda/ipipe0/pe5 eclk/pe4 v ssx vstby v ddx v ddpll xfc v sspll reset extal xtal kwh3/ph3 kwh2/ph2 kwh1/ph1 kwh0/ph0 lstrb /taglo /pe3 r/w /pe2 irq /pe1 xirq /pe0 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions pin assignments in 112-pin qfp mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 39 figure 3-2. 112-pin qfp mechanical dimensions (case no. 987) dim a min max 20.000 bsc millimeters a1 10.000 bsc b 20.000 bsc b1 10.000 bsc c --- 1.600 c1 0.050 0.150 c2 1.350 1.450 d 0.270 0.370 e 0.450 0.750 f 0.270 0.330 g 0.650 bsc j 0.090 0.170 k 0.500 ref p 0.325 bsc r1 0.100 0.200 r2 0.100 0.200 s 22.000 bsc s1 11.000 bsc v 22.000 bsc v1 11.000 bsc y 0.250 ref z 1.000 ref aa 0.090 0.160 11 11 13 7 13 ? l-m 0.20 n t 4x 4x 28 tips pin 1 ident 1 112 85 84 28 57 29 56 b v v1 b1 a1 s1 a s view ab 0.10 3 c c2 0.050 seating plane gage plane 1 ? 0.25 j1 view y j1 p g 108x 4x section j1-j1 base rotated 90 counterclockwise l-m m 0.13 n t 1 2 3 c l l-m 0.20 n t l n m t t 112x x x=l, m or n r r 8 3 0 notes: 1. dimensioning and tolerancing per asme y14.5m, 1994. 2. dimensions in millimeters. 3. datums l, m and n to be determined at seating plane, datum t. 4. dimensions s and v to be determined at seating plane, datum t. 5. dimensions a and b do not include mold protrusion. allowable protrusion is 0.25 per side. dimensions a and b include mold mismatch. 6. dimension d does not include dambar protrusion. allowable dambar protrusion shall not cause the d dimension to exceed 0.46. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 40 pinout and signal descriptions motorola 3.3 power supply pins power and ground pins are described below and summarized in table 3-1 . 3.3.1 internal power (v dd ) and ground (v ss ) power is supplied to the mcu through v dd and v ss . because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency characteristics and place them as close to the mcu as possible. bypass requirements depend on how heavily the mcu pins are loaded. 3.3.2 external power (v ddx ) and ground (v ssx ) external power and ground for i/o drivers. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency characteristics and place them as close to the mcu as possible. bypass requirements depend on how heavily the mcu pins are loaded. 3.3.3 v dda , v ssa provides operating voltage and ground for the analog-to-digital converter. this allows the supply voltage to the atd to be bypassed independently. connecting v dda to v dd if the atd modules are not used will not result in an increase of power consumption. 3.3.4 analog to digital reference voltages (v rh , v rl ) v rh0 , v rl0 : reference voltage high and low for atd converter 0. v rh1 , v rl1 : reference voltage high and low for atd converter 1. if the atd modules are not used, leaving v rh connected to v dd will not result in an increase of power consumption. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions power supply pins mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 41 3.3.5 v ddpll , v sspll provides operating voltage and ground for the phase-locked loop. this allows the supply voltage to the pll to be bypassed independently. note: the vsspll pin should always be grounded even if the pll is not used. the vddpll pin should not be left floating. it is recommended to connect the vddpll pin to ground if the pll is not used. 3.3.6 xfc pll loop filter. please see appendix: cgm practical aspects for information on how to calculate pll loop filter elements. any current leakage on this pin must be avoided. figure 3-3. pll loop filter connections if vddpll is connected to vss (this is normal case), then the xfc pin should either be left floating or connected to vss ( never to vdd). if vddpll is tied to vdd but the pll is switched off (pllon bit cleared), then the xfc pin should be connected preferably to vddpll (i.e. ready for vco minimum frequency). 3.3.7 v fp flash eeprom program/erase voltage and supply voltage during normal operation. mcu xfc r 0 c 0 c p vddpll f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 42 pinout and signal descriptions motorola 3.3.8 v stby stand-by voltage supply to static ram. used to maintain the contents of ram with minimal power when the rest of the chip is powered down. 3.4 signal descriptions 3.4.1 crystal driver and external clock input (xtal, extal) these pins provide the interface for either a crystal or a cmos compatible clock to control the internal clock generator circuitry. out of reset the frequency applied to extal is twice the desired e ? clock rate. all the device clocks are derived from the extal input frequency. note: crystal circuit is changed from standard. table 3-1. power and ground connection summary mnemonic pin number description 112-pin qfp v dd 12, 65 internal power and ground. v ss 14, 66 v ddx 42, 107 external power and ground, supply to pin drivers. v ssx 40, 106 v dda 85 operating voltage and ground for the analog-to-digital converter, allows the supply voltage to the a/d to be bypassed independently. v ssa 88 v rh1 86 reference voltages for the analog-to-digital converter 1 v rl1 87 v rh0 67 reference voltages for the analog-to-digital converter 0. v rl0 68 v ddpll 43 provides operating voltage and ground for the phase-locked loop. this allows the supply voltage to the pll to be bypassed independently. v sspll 45 v fp 97 program/erase voltage for the flash eeprom and required supply for normal operation. v stby 41 stand-by voltage supply to maintain the contents of ram with minimal power when the rest of the chip is powered down. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions signal descriptions mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 43 note: the internal return path for the oscillator is the vsspll pin. therefore it is recommended to connect the common node of the resonator and the capacitor directly to the vsspll pin. figure 3-4. common crystal connections note: when selecting a crystal, it is recommended to use one with the lowest possible frequency in order to minimise emc emissions. figure 3-5. external oscillator connections xtal is the crystal output.the xtal pin must be left unterminated when an external cmos compatible clock input is connected to the extal pin. the xtal output is normally intended to drive only a crystal. the xtal output can be buffered with a high-impedance buffer to drive the extal input of another device. in all cases take extra care in the circuit board layout around the oscillator pins. load capacitances in the oscillator circuits include all stray layout capacitances. refer to figure 3-4 and figure 3-5 for diagrams of oscillator circuits. c1 mcu c2 extal xtal 2 x e crystal or ceramic resonator nc mcu extal xtal 2 x e cmos-compatible external oscillator f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 44 pinout and signal descriptions motorola 3.4.2 e-clock output (eclk) eclk is the output connection for the internal bus clock. it is used to demultiplex the address and data in expanded modes and is used as a timing reference. eclk frequency is equal to 1/2 the crystal frequency out of reset. the e-clock output is turned off in single chip user mode to reduce the effects of rfi. it can be turned on if necessary. in special single-chip mode, the e-clock is turned on at reset and can be turned off. in special peripheral mode the e-clock is an input to the mcu. all clocks, including the e clock, are halted when the mcu is in stop mode. it is possible to configure the mcu to interface to slow external memory. eclk can be stretched for such accesses. 3.4.3 reset (reset ) an active low bidirectional control signal, reset , acts as an input to initialize the mcu to a known start-up state. it also acts as an open-drain output to indicate that an internal failure has been detected in either the clock monitor or cop watchdog circuit. the mcu goes into reset asynchronously and comes out of reset synchronously. this allows the part to reach a proper reset state even if the clocks have failed, while allowing synchronized operation when starting out of reset. it is important to use an external low-voltage reset circuit (such as mc34064 or mc34164) to prevent corruption of ram or eeprom due to power transitions. the reset sequence is initiated by any of the following events:  power-on-reset (por)  cop watchdog enabled and watchdog timer times out  clock monitor enabled and clock monitor detects slow or stopped clock  user applies a low level to the reset pin external circuitry connected to the reset pin should not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic one within nine bus cycles after the low drive is released. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions signal descriptions mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 45 upon detection of any reset, an internal circuit drives the reset pin low and a clocked reset sequence controls when the mcu can begin normal processing. in the case of por or a clock monitor error, a 4096 cycle oscillator startup delay is imposed before the reset recovery sequence starts (reset is driven low throughout this 4096 cycle delay). the internal reset recovery sequence then drives reset low for 16 to 17 cycles and releases the drive to allow reset to rise. nine cycles later this circuit samples the reset pin to see if it has risen to a logic one level. if reset is low at this point, the reset is assumed to be coming from an external request and the internally latched states of the cop time-out and clock monitor failure are cleared so the normal reset vector ($fffe:ffff) is taken when reset is finally released. if reset is high after this nine cycle delay, the reset source is tentatively assumed to be either a cop failure or a clock monitor fail. if the internally latched state of the clock monitor fail circuit is true, processing begins by fetching the clock monitor vector ($fffc:fffd). if no clock monitor failure is indicated, and the latched state of the cop time-out is true, processing begins by fetching the cop vector ($fffa:fffb). if neither clock monitor fail nor cop time-out are pending, processing begins by fetching the normal reset vector ($fffe:ffff). 3.4.4 maskable interrupt request (irq ) the irq input provides a means of applying asynchronous interrupt requests to the mcu. either falling edge-sensitive triggering or level- sensitive triggering is program selectable (intcr register). irq is always enabled and configured to level-sensitive triggering at reset. it can be disabled by clearing the irqen bit (intcr register). when the mcu is reset, the irq function is masked in the condition code register. this pin is always an input and can always be read. there is an active pull-up on this pin while in reset and immediately out of reset. the pull- up can be turned off by clearing pupe in the pucr register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 46 pinout and signal descriptions motorola 3.4.5 nonmaskable interrupt (xirq ) the xirq input provides a means of requesting a nonmaskable interrupt after reset initialization. during reset, the x bit in the condition code register (ccr) is set and any interrupt is masked until mcu software enables it. because the xirq input is level sensitive, it can be connected to a multiple-source wired-or network. this pin is always an input and can always be read. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupe in the pucr register. xirq is often used as a power loss detect interrupt. whenever xirq or irq are used with multiple interrupt sources (irq must be configured for level-sensitive operation if there is more than one source of irq interrupt), each source must drive the interrupt input with an open-drain type of driver to avoid contention between outputs. there must also be an interlock mechanism at each interrupt source so that the source holds the interrupt line low until the mcu recognizes and acknowledges the interrupt request. if the interrupt line is held low, the mcu will recognize another interrupt as soon as the interrupt mask bit in the mcu is cleared (normally upon return from an interrupt). 3.4.6 mode select (smodn, moda, and modb) the state of these pins during reset determine the mcu operating mode. after reset, moda and modb can be configured as instruction queue tracking signals ipipe0 and ipipe1 in expanded modes. moda and modb have active pull-downs during reset. the smodn pin has an active pull-up when configured as an input. this pin can be used as bkgd or taghi after reset. 3.4.7 single-wire background mode pin (bkgd) the bkgd pin receives and transmits serial background debugging commands. a special self-timing protocol is used. the bkgd pin has an active pull-up when configured as an input; bkgd has no pull-up control. refer to development support . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions signal descriptions mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 47 3.4.8 external address and data buses (addr[15:0] and data[15:0]) external bus pins share functions with general-purpose i/o ports a and b. in single-chip operating modes, the pins can be used for i/o; in expanded modes, the pins are used for the external buses. in expanded wide mode, ports a and b are used for multiplexed 16-bit data and address buses. pa[7:0] correspond to addr[15:8]/data[15:8]; pb[7:0] correspond to addr[7:0]/data[7:0]. in expanded narrow mode, ports a and b are used for the16-bit address bus, and an 8-bit data bus is multiplexed with the most significant half of the address bus on port a. in this mode, 16-bit data is handled as two back-to-back bus cycles, one for the high byte followed by one for the low byte. pa[7:0] correspond to addr[15:8] and to data[15:8] or data[7:0], depending on the bus cycle. the state of the address pins should be latched at the rising edge of e. to allow for maximum address setup time at external devices, a transparent latch should be used. 3.4.9 read/write (r/w ) in all modes this pin can be used as a general-purpose i/o and is an input with an active pull-up out of reset. if the read/write function is required it should be enabled by setting the rdwe bit in the pear register. external writes will not be possible until enabled. 3.4.10 low-byte strobe (lstrb) in all modes this pin can be used as a general-purpose i/o and is an input with an active pull-up out of reset. if the strobe function is required, it should be enabled by setting the lstre bit in the pear register. this signal is used in write operations and so external low byte writes will not be possible until this function is enabled. this pin is also used as taglo in special expanded modes and is multiplexed with the lstrb function. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 48 pinout and signal descriptions motorola 3.4.11 instruction queue tracking signals (ipipe1 and ipipe0) these signals are used to track the state of the internal instruction execution queue. execution state is time-multiplexed on the two signals. refer to development support . 3.4.12 data bus enable (dbe ) the dbe pin (pe7) is an active low signal that will be asserted low during e-clock high time. dbe provides separation between output of a multiplexed address and the input of data. when an external address is stretched, dbe is asserted during what would be the last quarter cycle of the last e-clock cycle of stretch. in expanded modes this pin is used to enable the drive control of external buses during external reads. use of the dbe is controlled by the ndbe bit in the pear register. d be is enabled out of reset in expanded modes. this pin has an active pull-up during and after reset in single chip modes. 3.4.13 inverted e clock (eclk ) the eclk pin (pe7) can be used to latch the address for de- multiplexing. it has the same behavior as the eclk, except is inverted. in expanded modes this pin is used to enable the drive control of external buses during external reads. use of the eclk is controlled by the ndbe and dbene bits in the pear register. 3.4.14 calibration reference (cal) the cal pin (pe7) is the output of the slow mode programmable clock divider, slwclk, and is used as a calibration reference. the slwclk frequency is equal to the crystal frequency out of reset and always has a 50% duty. if the dbe function is enabled it will override the enabled cal output. the cal pin output is disabled by clearing cale bit in the pear register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions signal descriptions mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 49 3.4.15 clock generation module test (cgmtst) the cgmtst pin (pe6) is the output of the clocks tested when cgmte bit is set in pear register. the pipoe bit must be cleared for the clocks to be tested. table 3-2. signal description summary pin name shared port pin number description 112-pin extal - 47 crystal driver and external clock input pins. on reset all the device clocks are derived from the extal input frequency. xtal is the crystal output. xtal - 48 reset - 46 an active low bidirectional control signal, reset acts as an input to initialize the mcu to a known start-up state, and an output when cop or clock monitor causes a reset. addr[7:0] data[7:0] pb[7:0] 31 ? 24 external bus pins share function with general-purpose i/o ports a and b. in single chip modes, the pins can be used for i/o. in expanded modes, the pins are used for the external buses. addr[15:8] data[15:8] pa[7:0] 64 ? 57 dbe pe7 36 data bus control and, in expanded mode, enables the drive control of external buses during external reads. eclk pe7 36 inverted e clock used to latch the address. cal pe7 36 cal is the output of the slow mode programmable clock divider, slwclk, and is used as a calibration reference for functions such as time of day. it is overridden when dbe function is enabled. it always has a 50% duty. cgmtst pe6 37 clock generation module test output. modb/ ipipe1, moda/ ipipe0 pe6, pe5 37, 38 state of mode select pins during reset determine the initial operating mode of the mcu. after reset, modb and moda can be configured as instruction queue tracking signals ipipe1 and ipipe0 or as general- purpose i/o pins. eclk pe4 39 e clock is the output connection for the external bus clock. eclk is used as a timing reference and for address demultiplexing. lstrb/ taglo pe3 53 low byte strobe (0 = low byte valid), in all modes this pin can be used as i/o. the low strobe function is the exclusive-nor of a0 and the internal sz8 signal. (the sz8 internal signal indicates the size 16/8 access.) pin function taglo used in instruction tagging. see development support . r/w pe2 54 indicates direction of data on expansion bus. shares function with general-purpose i/o. read/write in expanded modes. irq pe1 55 maskable interrupt request input provides a means of applying asynchronous interrupt requests to the mcu. either falling edge- sensitive triggering or level-sensitive triggering is program selectable (intcr register). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 50 pinout and signal descriptions motorola xirq pe0 56 provides a means of requesting asynchronous nonmaskable interrupt requests after reset initialization smodn/ bkgd/ taghi -23 during reset, this pin determines special or normal operating mode. after reset, single-wire background interface pin is dedicated to the background debug function. pin function taghi used in instruction tagging. see development support . ix[2:0] pk[2:0] 109-111 page index register emulation outputs. ecs pk7 108 emulation chip select. pw[3:0] pp[3:0] 112, 1 ? 3 pulse width modulator channel outputs. ss ps7 96 slave select output for spi master mode, input for slave mode or master mode. sck ps6 95 serial clock for spi system. sdo/mosi ps5 94 master out/slave in pin for serial peripheral interface sdi/miso ps4 93 master in/slave out pin for serial peripheral interface txd1 ps3 92 sci1 transmit pin rxd1 ps2 91 sci1 receive pin txd0 ps1 90 sci0 transmit pin rxd0 ps0 89 sci0 receive pin ioc[7:0] pt[7:0] 18 ? 15, 7 ? 4 pins used for input capture and output compare in the timer and pulse accumulator subsystem. an1[7:0] pad1[7:0] 84/82/80/7 8/76/74/72/ 70 analog inputs for the analog-to-digital conversion module 1 an0[7:0] pad0[7:0] 83/81/79/7 7/75/73/71/ 69 analog inputs for the analog-to-digital conversion module 0 txcan1 - 102 mscan1 transmit pin rxcan1 - 103 mscan1 receive pin txcan0 - 104 mscan0 transmit pin rxcan0 - 105 mscan0 receive pin scl pib7 98 i 2 c bus serial clock line pin sda pib6 99 i 2 c bus serial data line pin kwj[7:0] pj[7:0] 8 ? 11, 19 ? 22 key wake-up and general purpose i/o; can cause an interrupt when an input transitions from high to low or from low to high (kwpj). kwh[7:0] ph[7:0] 32 ? 35, 49 ? 52 key wake-up and general purpose i/o; can cause an interrupt when an input transitions from high to low or from low to high (kwph). table 3-2. signal description summary pin name shared port pin number description 112-pin f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions port signals mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 51 3.5 port signals the mc68hc912dg128 incorporates eleven ports which are used to control and access the various device subsystems. when not used for these purposes, port pins may be used for general-purpose i/o. in addition to the pins described below, each port consists of a data register which can be read and written at any time, and, with the exception of port ad0, port ad1, pe[1:0], rxcan and txcan, a data direction register which controls the direction of each pin. after reset all general purpose i/o pins are configured as input. 3.5.1 port a port a pins are used for address and data in expanded modes. in single chip modes, the pins can be used as general purpose i/o. the port data register is not in the address map during expanded and peripheral mode operation. when it is in the map, port a can be read or written at anytime. register ddra determines whether each port a pin is an input or output. ddra is not in the address map during expanded and peripheral mode operation. setting a bit in ddra makes the corresponding bit in port a an output; clearing a bit in ddra makes the corresponding bit in port a an input. the default reset state of ddra is all zeros. when the pupa bit in the pucr register is set, all port a input pins are pulled-up internally by an active pull-up device. pucr is not in the address map in peripheral mode. setting the rdpa bit in register rdriv causes all port a outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.2 port b port b pins are used for address and data in expanded modes. in single chip modes, the pins can be used as general purpose i/o. the port data register is not in the address map during expanded and peripheral mode operation. when it is in the map, port b can be read or written at anytime. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 52 pinout and signal descriptions motorola register ddrb determines whether each port b pin is an input or output. ddrb is not in the address map during expanded and peripheral mode operation. setting a bit in ddrb makes the corresponding bit in port b an output; clearing a bit in ddrb makes the corresponding bit in port b an input. the default reset state of ddrb is all zeros. when the pupb bit in the pucr register is set, all port b input pins are pulled-up internally by an active pull-up device. pucr is not in the address map in peripheral mode. setting the rdpb bit in register rdriv causes all port b outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.3 port e port e pins operate differently from port a and b pins. port e pins are used for bus control signals and interrupt service request signals. when a pin is not used for one of these specific functions, it can be used as general-purpose i/o. however, two of the pins (pe[1:0]) can only be used for input, and the states of these pins can be read in the port data register even when they are used for irq and xirq . the pear register determines pin function, and register ddre determines whether each pin is an input or output when it is used for general-purpose i/o. pear settings override ddre settings. because pe[1:0] are input-only pins, only ddre[7:2] have effect. setting a bit in the ddre register makes the corresponding bit in port e an output; clearing a bit in the ddre register makes the corresponding bit in port e an input. the default reset state of ddre is all zeros. when the pupe bit in the pucr register is set, pe[7,3,2,1,0] are pulled up. pe[7,3,2,0] are active pull-up devices. pupcr is not in the address map in peripheral mode. neither port e nor ddre is in the map in peripheral mode; neither is in the internal map in expanded modes with eme set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions port signals mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 53 setting the rdpe bit in register rdriv causes all port e outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.4 port h port h pins are used for key wake-ups that can be used with the pins configured as inputs or outputs. the key wake-ups are triggered with either a rising or falling edge signal (kwph). an interrupt is generated if the corresponding bit is enabled (kwieh). if any of the interrupts is not enabled, the corresponding pin can be used as a general purpose i/o pin. refer to i/o ports with key wake-up . register ddrh determines whether each port h pin is an input or output. setting a bit in ddrh makes the corresponding bit in port h an output; clearing a bit in ddrh makes the corresponding bit in port h an input. the default reset state of ddrh is all zeros. register kwph not only determines what type of edge the key wake ups are triggered, but it also determines what type of resistive load is used for port h input pins when puph bit is set in the pucr register. setting a bit in kwph makes the corresponding key wake up input pin trigger at rising edges and loads a pull down in the corresponding port h input pin. clearing a bit in kwph makes the corresponding key wake up input pin trigger at falling edges and loads a pull up in the corresponding port h input pin. the default state of kwph is all zeros. setting the rdph bit in register rdriv causes all port h outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.5 port j port j pins are used for key wake-ups that can be used with the pins configured as inputs or outputs. the key wake-ups are triggered with either a rising or falling edge signal (kwpj). an interrupt is generated if f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 54 pinout and signal descriptions motorola the corresponding bit is enabled (kwiej). if any of the interrupts is not enabled, the corresponding pin can be used as a general purpose i/o pin. refer to i/o ports with key wake-up . register ddrj determines whether each port j pin is an input or output. setting a bit in ddrj makes the corresponding bit in port j an output; clearing a bit in ddrj makes the corresponding bit in port j an input. the default reset state of ddrj is all zeros. register kwpj not only determines what type of edge the key wake ups are triggered, but it also determines what type of resistive load is used for port j input pins when pupj bit is set in the pucr register. setting a bit in kwpj makes the corresponding key wake up input pin trigger at rising edges and loads a pull down in the corresponding port j input pin. clearing a bit in kwpj makes the corresponding key wake up input pin trigger at falling edges and loads a pull up in the corresponding port j input pin. the default state of kwpj is all zeros. setting the rdpj bit in register rdriv causes all port j outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.6 port k port k pins are used for page index emulation in expanded or peripheral modes. when page index emulation is not enabled, emk is not set in mode register, or the part is in single chip mode, these pins can be used for general purpose i/o. port k bit 3 is used as a general purpose i/o pin only. the port data register is not in the address map during expanded and peripheral mode operation with emk set. when it is in the map, port k can be read or written at anytime. register ddrk determines whether each port k pin is an input or output. ddrk is not in the address map during expanded and peripheral mode operation with emk set. setting a bit in ddrk makes the corresponding bit in port k an output; clearing a bit in ddrk makes the corresponding bit in port k an input. the default reset state of ddrk is all zeros. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions port signals mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 55 when the pupk bit in the pucr register is set, all port k input pins are pulled-up internally by an active pull-up device. pucr is not in the address map in peripheral mode. setting the rdpk bit in register rdriv causes all port k outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to bus control and input/output . 3.5.7 port can1 the mscan1 uses two external pins, one input (rxcan1) and one output (txcan1). the txcan1 output pin represents the logic level on the can: ? 0 ? is for a dominant state, and ? 1 ? is for a recessive state. rxcan1 is on bit 0 of port can1, txcan1 is on bit 1. 3.5.8 port can0 the mscan0 uses two external pins, one input (rxcan0) and one output (txcan0). the txcan0 output pin represents the logic level on the can: ? 0 ? is for a dominant state, and ? 1 ? is for a recessive state. rxcan0 is on bit 0 of port can0, txcan0 is on bit 1. 3.5.9 port ib bidirectional pins to iic bus interface subsystem. the iic bus interface uses a serial data line (sda) and serial clock line (scl) for data transfer. the pins are connected to a positive voltage supply via a pull up resistor. the pull ups can be enabled internally or connected externally. the output stages have open drain outputs in order to perform the wired-and function. when the iic is disabled the pins can be used as general purpose i/o pins. scl is on bit 7 of port ib and sda is on bit 6. the remaining pins of port ib (pib[5:4]) are controlled by registers in the iic address space. register ddrib determines pin direction of port ib when used for general-purpose i/o. when ddrib bits are set, the corresponding pin is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 56 pinout and signal descriptions motorola configured for output. on reset the ddrib bits are cleared and the corresponding pin is configured for input. when the pupib bit in the ibpurd register is set, all input pins are pulled up internally by an active pull-up device. pull-ups are disabled after reset, except for input ports 0 through 3, which are always on regardless of pupib bit. setting the rdpib bit in the ibpurd register configures all port ib outputs to have reduced drive levels. levels are at normal drive capability after reset. the ibpurd register can be read or written anytime after reset. refer to section inter-ic bus . 3.5.10 port ad1 this port is an analog input interface to the analog-to-digital subsystem and used for general-purpose input. when analog-to-digital functions are not enabled, the port has eight general-purpose input pins, pad1[7:0]. the adpu bit in the atd1ctl2 register enables the a/d function. port ad1 pins are inputs; no data direction register is associated with this port. the port has no resistive input loads and no reduced drive controls. refer to mscan controller . 3.5.11 port ad0 this port is an analog input interface to the analog-to-digital subsystem and used for general-purpose input. when analog-to-digital functions are not enabled, the port has eight general-purpose input pins, pad0[7:0]. the adpu bit in the atd0ctl2 register enables the a/d function. port ad0 pins are inputs; no data direction register is associated with this port. the port has no resistive input loads and no reduced drive controls. refer to mscan controller . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions port signals mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 57 3.5.12 port p the four pulse-width modulation channel outputs share general-purpose port p pins. the pwm function is enabled with the pwen register. enabling pwm pins takes precedence over the general-purpose port. when pulse-width modulation is not in use, the port pins may be used for general-purpose i/o. register ddrp determines pin direction of port p when used for general-purpose i/o. when ddrp bits are set, the corresponding pin is configured for output. on reset the ddrp bits are cleared and the corresponding pin is configured for input. when the pupp bit in the pwctl register is set, all input pins are pulled up internally by an active pull-up device. pull-ups are disabled after reset. setting the rdpp bit in the pwctl register configures all port p outputs to have reduced drive levels. levels are at normal drive capability after reset. the pwctl register can be read or written anytime after reset. refer to pulse width modulator . 3.5.13 port s port s is the 8-bit interface to the standard serial interface consisting of the two serial communications interfaces (sci1 and sci0) and the serial peripheral interface (spi) subsystems. port s pins are available for general-purpose i/o when standard serial functions are not enabled. port s pins serve several functions depending on the various internal control registers. if woms bit in the sc0cr1register is set, the p- channel drivers of the output buffers are disabled (wire-or mode) for pins 0 through 3. if swom bit in the sp0cr1 register is set, the p-channel drivers of the output buffers are disabled (wire-or mode) for pins 4 through 7. the open drain control affects both the serial and the general- purpose outputs. if the rdps bit in the sp0cr2 register is set, port s pin drive capabilities are reduced. if pups bit in the sp0cr2 register is set, a pull-up device is activated for each port s pin programmed as a general purpose input. if the pin is programmed as a general-purpose output, the pull-up is disconnected from the pin regardless of the state of pups bit. see multiple serial interface . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 58 pinout and signal descriptions motorola 3.5.14 port t this port provides eight general-purpose i/o pins when not enabled for input capture and output compare in the timer and pulse accumulator subsystem. the ten bit in the tscr register enables the timer function. the pulse accumulator subsystem is enabled with the paen bit in the pactl register. register ddrt determines pin direction of port t when used for general- purpose i/o. when ddrt bits are set, the corresponding pin is configured for output. on reset the ddrt bits are cleared and the corresponding pin is configured for input. when the pupt bit in the tmsk2 register is set, all input pins are pulled up internally by an active pull-up device. pull-ups are disabled after reset. setting the rdpt bit in the tmsk2 register configures all port t outputs to have reduced drive levels. levels are at normal drive capability after reset. the tmsk2 register can be read or written anytime after reset refer to enhanced capture timer . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions port signals mc68hc912dg128 ? rev 3.0 technical data motorola pinout and signal descriptions 59 table 3-3. port description summary port name pin numbers data direction register (address) description 112-pin port a pa[7:0] 64-57 in/out ddra ($0002) port a and port b pins are used for address and data in expanded modes. the port data registers are not in the address map during expanded and peripheral mode operation. when in the map, port a and port b can be read or written any time. ddra and ddrb are not in the address map in expanded or peripheral modes. port b pb[7:0] 31 ? 24 in/out ddrb ($0003) port ad1 pad1[7:0] 84/82/80/78/7 6/74/72/70 in analog-to-digital converter 1 and general-purpose i/o. port ad0 pad0[7:0] 83/81/79/77/7 5/73/71/69 in analog-to-digital converter 0 and general-purpose i/o. port can1 pcan1[1:0] 102 ? 103 pcan1[1] out pcan1[0] in pcan1[1:0] are used with the mscan1 module and cannot be used as general purpose i/o. port can0 pcan0[1:0] 104 ? 105 pcan0[1] out pcan0[0] in pcan0[1:0] are used with the mscan0 module and cannot be used as general purpose i/o. port ib pib[7:4] 98 ? 101 in/out ddrib ($00e7) general purpose i/o. pib[7:6] are used with the i-bus module when enabled. port ib pib[3:2] 102 ? 103 in/out ddrib ($00e7) general purpose i/o port e pe[7:0] 36 ? 39, 53 ? 56 pe[1:0] in pe[7:2] in/out ddre ($0009) mode selection, bus control signals and interrupt service request signals; or general-purpose i/o. port k pk[7,3:0] 13, 108-111 in/out ddrk ($00fd) page index emulation signals in expanded or peripheral mode or general-purpose i/o. port p pp[3:0] 112, 1 ? 3 in/out ddrp ($0057) general-purpose i/o. pp[3:0] are used with the pulse-width modulator when enabled. port s ps[7:0] 96 ? 89 in/out ddrs ($00d7) serial communications interfaces 1 and 0 and serial peripheral interface subsystems; or general-purpose i/o. port t pt[7:0] 18 ? 15, 7 ? 4 in/out ddrt ($00af) general-purpose i/o when not enabled for input capture and output compare in the timer and pulse accumulator subsystem. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 60 pinout and signal descriptions motorola 3.5.15 port pull-up pull-down and reduced drive mcu ports can be configured for internal pull-up. to reduce power consumption and rfi, the pin output drivers can be configured to operate at a reduced drive level. reduced drive causes a slight increase in transition time depending on loading and should be used only for ports which have a light loading. table 3-4 summarizes the port pull-up/pull- down default status and controls. table 3-4. port pull-up, pull-down and reduced drive summary enable bit reduced drive control bit port name resistive input loads register (address) bit name reset state register (address) bit name reset state port a pull-up pucr ($000c) pupa disabled rdriv ($000d) rdpa full drive port b pull-up pucr ($000c) pupb disabled rdriv ($000d) rdpb full drive port e: pe7, pe[3:2] pull-up pucr ($000c) pupe enabled rdriv ($000d) rdpe full drive pe[1:0] pull-up pucr ($000c) pupe enabled ? pe[6:4] none ? rdriv ($000d) rdpe full drive port h pull-up or pull-down pucr ($000c) puph disabled rdriv ($000d) rdph full drive port j pull-up or pull-down pucr ($000c) pupj disabled rdriv ($000d) rdpj full drive port k pull-up pucr ($000c) pupk disabled rdriv ($000d) rdpk full drive port p pull-up pwctl ($0054) pupp disabled pwctl ($0054) rdpp full drive port s pull-up sp0cr2 ($00d1) pups enabled sp0cr2 ($00d1) rdps full drive port t pull-up tmsk2 ($008d) tpu disabled tmsk2 ($008d) tdrb full drive port ib[7:4] pull-up ibpurd ($00e5) pupib disabled ibpurd ($00e5) rdpib full drive port ib[3:2] pull-up always enabled when pins are input ibpurd ($00e5) rdpib full drive port ad0 none ?? port ad1 none ?? port can1[1] none ?? port can1[0] pull-up always enabled ? port can0[1] none ?? port can0[0] pull-up always enabled ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 61 pinout and signal descriptions motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pinout and signal descriptions technical data mc68hc912dg128 ? rev 3.0 62 pinout and signal descriptions motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola registers 63 technical data ? mc68hc912dg128 section 4. registers 4.1 contents 4.2 register block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.2 register block the register block can be mapped to any 2k byte boundary within the standard 64k byte address space by manipulating bits reg[15:11] in the initrg register. initrg establishes the upper five bits of the register block ? s 16-bit address. the register block occupies the first 1k byte of the 2k byte block. default addressing (after reset) is indicated in the table below. for additional information refer to general description . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 64 registers motorola address bit 7 6 5 4 3 2 1 bit 0 name $0000pa7pa6pa5pa4pa3pa2pa1pa0 porta (1) $0001 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 portb (1) $0002 dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 ddra (1) $0003 ddb7 ddb6 ddb5 ddb4 ddb3 ddb2 ddb1 ddb0 ddrb (1) $0004- $0007 00000000 reserved (3) $0008 pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 porte (2) $0009 dde7 dde6 dde5 dde4 dde3 dde2 0 0 ddre (2) $000a ndbe cgmte pipoe neclk lstre rdwe cale dbene pear (3) $000b smodn modb moda estr ivis ebswai emk eme mode (3) $000c pupk pupj puph pupe 0 0 pupb pupa pucr (3) $000d rdpk rdpj rdph rdpe 0 0 rdpb rdpa rdriv (3) $000e00000000 reserved (3) $000f00000000 reserved (3) $0010ram15ram14ram1300000initrm $0011 reg15 reg14 reg13 reg12 reg11 0 0 mmswai initrg $0012 ee15 ee14 ee13 ee12 0 0 0 eeon initee $0013 romtst ndrf rfstr1 rfstr0 exstr1 exstr0 romhm romon misc $0014 rtie rswai rsbck reserved rtbyp rtr2 rtr1 rtr0 rtictl $0015rtif0000000rtiflg $0016 cme fcme fcmcop wcop disr cr2 cr1 cr0 copctl $0017bit 7654321bit 0coprst $0018 ite6 ite8 itea itec itee itf0 itf2 itf4 itst0 $0019 itd6 itd8 itda itdc itde ite0 ite2 ite4 itst1 $001a itc6 itc8 itca itcc itce itd0 itd2 itd4 itst2 $001b itb6 itb8 itba itbc itbe itc0 itc2 itc4 itst3 $001c00000000reserved $001d00000000reserved $001eirqeirqendly00000intcr $001f 1 psel6 psel5 psel4 psel3 psel2 psel1 0 hprio $0020 bken1 bken0 bkpm 0 bk1ale bk0ale 0 0 brkct0 $0021 0 bkdbe bkmbh bkmbl bk1rwe bk1rw bk0rwe bk0rw brkct1 $0022 bit 15 14 13 12 11 10 9 bit 8 brkah $0023bit 7654321bit 0brkal $0024 bit 15 14 13 12 11 10 9 bit 8 brkdh table 4-1. register map (sheet 1 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers register block mc68hc912dg128 ? rev 3.0 technical data motorola registers 65 $0025bit 7654321bit 0brkdl $002600000000reserved $002700000000reserved $0028pj7pj6pj5pj4pj3pj2pj1pj0portj $0029ph7ph6ph5ph4ph3ph2ph1ph0porth $002a ddj7 ddj6 ddj5 ddj4 ddj3 ddj2 ddj1 ddj0 ddrj $002b ddh7 ddh6 ddh5 ddh4 ddh3 ddh2 ddh1 ddh0 ddrh $002c kwiej7 kwiej6 kwiej5 kwiej4 kwiej3 kwiej2 kwiej1 kwiej0 kwiej $002d kwieh7 kwieh6 kwieh5 kwieh4 kwieh3 kwieh2 kwieh1 kwieh0 kwieh $002e kwifj7 kwifj6 kwifj5 kwifj4 kwifj3 kwifj2 kwifj1 kwifj0 kwifj $002f kwifh7 kwifh6 kwifh5 kwifh4 kwifh3 kwifh2 kwifh1 kwifh0 kwifh $0030 kwpj7 kwpj6 kwpj5 kwpj4 kwpj3 kwpj2 kwpj1 kwpj0 kwpj $0031 kwph7 kwph6 kwph5 kwph4 kwph3 kwph2 kwph1 kwph0 kwph $003200000000reserved $003300000000reserved $0034 ? $0037 unimplemented (4) reserved $0038 0 0 syn5 syn4 syn3 syn2 syn1 syn0 synr $003900000refdv2refdv1refdv0refdv $003a tstout7 tstout6 tstout5 tstout4 tstout3 tstout2 tstout1 tstout0 cgtflg $003b lockif lock 0 0 0 0 lhif lhome pllflg $003c lockie pllon auto acq 0 pstp lhie nolhm pllcr $003d 0 bcsp bcss 0 0 mcs 0 0 clksel $003e 0 0 sldv5 sldv4 sldv3 sldv2 sldv1 sldv0 slow $003fopnletrktstclketst4tst3tst2tst1tst0cgtctl $0040 con23 con01 pcka2 pcka1 pcka0 pckb2 pckb1 pckb0 pwclk $0041 pclk3 pclk2 pclk1 pclk0 ppol3 ppol2 ppol1 ppol0 pwpol $00420000pwen3pwen2pwen1pwen0pwen $0043 0 bit 6 5 4 3 2 1 bit 0 pwpres $0044bit 7654321bit 0pwscal0 $0045bit 7654321bit 0pwscnt0 $0046bit 7654321bit 0pwscal1 $0047bit 7654321bit 0pwscnt1 $0048bit 7654321bit 0pwcnt0 $0049bit 7654321bit 0pwcnt1 $004abit 7654321bit 0pwcnt2 $004bbit 7654321bit 0pwcnt3 $004cbit 7654321bit 0pwper0 address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 2 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 66 registers motorola $004dbit 7654321bit 0pwper1 $004ebit 7654321bit 0pwper2 $004fbit 7654321bit 0pwper3 $0050bit 7654321bit 0pwdty0 $0051bit 7654321bit 0pwdty1 $0052bit 7654321bit 0pwdty2 $0053bit 7654321bit 0pwdty3 $0054 0 0 0 pswai centr rdpp pupp psbck pwctl $0055discrdiscpdiscal00000pwtst $0056 pp7 pp6 pp5 pp4 pp3 pp2 pp1 pp0 portp $0057 ddp7 ddp6 ddp5 ddp4 ddp3 ddp2 ddp1 ddp0 ddrp $0058- $005f 00000000reserved $0060 reserved atd0ctl0 $0061 reserved atd0ctl1 $0062 adpu affc aswai 0 0 0 ascie ascif atd0ctl2 $0063000000frz1frz0atd0ctl3 $0064 res10 smp1 smp0 prs4 prs3 prs2 prs1 prs0 atd0ctl4 $0065 0 s8cm scan mult cd cc cb ca atd0ctl5 $0066 scf 0 0 0 0 cc2 cc1 cc0 atd0stat0 $0067 ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 atd0stat1 $0068 sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 atd0testh $0069 sar1 sar0 rst tstout tst3 tst2 tst1 tst0 atd0testl $006a ? $ 006e 00000000reserved $006f pad07 pad06 pad05 pad04 pad03 pad02 pad01 pad00 portad0 $0070 bit 15 14 13 12 11 10 9 bit 8 adr00h $0071bit 7bit 6000000adr00l $0072 bit 15 14 13 12 11 10 9 bit 8 adr01h $0073bit 7bit 6000000adr01l $0074 bit 15 14 13 12 11 10 9 bit 8 adr02h $0075bit 7bit 6000000adr02l $0076 bit 15 14 13 12 11 10 9 bit 8 adr03h $0077bit 7bit 6000000adr03l $0078 bit 15 14 13 12 11 10 9 bit 8 adr04h $0079bit 7bit 6000000adr04l $007a bit 15 14 13 12 11 10 9 bit 8 adr05h $007bbit 7bit 6000000adr05l $007c bit 15 14 13 12 11 10 9 bit 8 adr06h address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 3 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers register block mc68hc912dg128 ? rev 3.0 technical data motorola registers 67 $007dbit 7bit 6000000adr06l $007e bit 15 14 13 12 11 10 9 bit 8 adr07h $007fbit 7bit 6000000adr07l $0080 ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 tios $0081 foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 cforc $0082 oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 oc7m $0083 oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 oc7d $0084 bit 15 14 13 12 11 10 9 bit 8 tcnt $0085bit 7654321bit 0tcnt $0086 ten tswai tsbck tffca reserved tscr $0087 reserved tqcr $0088 om7 ol7 om6 ol6 om5 ol5 om4 ol4 tctl1 $0089 om3 ol3 om2 ol2 om1 ol1 om0 ol0 tctl2 $008a edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a tctl3 $008b edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a tctl4 $008c c7i c6i c5i c4i c3i c2i c1i c0i tmsk1 $008d toi 0 pupt rdpt tcre pr2 pr1 pr0 tmsk2 $008e c7f c6f c5f c4f c3f c2f c1f c0f tflg1 $008ftof0000000tflg2 $0090 bit 15 14 13 12 11 10 9 bit 8 tc0 $0091bit 7654321bit 0tc0 $0092 bit 15 14 13 12 11 10 9 bit 8 tc1 $0093bit 7654321bit 0tc1 $0094 bit 15 14 13 12 11 10 9 bit 8 tc2 $0095bit 7654321bit 0tc2 $0096 bit 15 14 13 12 11 10 9 bit 8 tc3 $0097bit 7654321bit 0tc3 $0098 bit 15 14 13 12 11 10 9 bit 8 tc4 $0099bit 7654321bit 0tc4 $009a bit 15 14 13 12 11 10 9 bit 8 tc5 $009bbit 7654321bit 0tc5 $009c bit 15 14 13 12 11 10 9 bit 8 tc6 $009dbit 7654321bit 0tc6 $009e bit 15 14 13 12 11 10 9 bit 8 tc7 $009fbit 7654321bit 0tc7 $00a0 0 paen pamod pedge clk1 clk0 paovi pai pactl $00a1000000paovfpaifpaflg $00a2bit 7654321bit 0pacn3 address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 4 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 68 registers motorola $00a3bit 7654321bit 0pacn2 $00a4bit 7654321bit 0pacn1 $00a5bit 7654321bit 0pacn0 $00a6 mczi modmc rdmcl iclat flmc mcen mcpr1 mcpr0 mcctl $00a7 mczf 0 0 0 polf3 polf2 polf1 polf0 mcflg $00a80000pa3enpa2enpa1enpa0enicpar $00a9000000dly1dly0dlyct $00aa novw7 novw6 novw5 novw4 novw3 novw2 novw1 novw0 icovw $00ab sh37 sh26 sh15 sh04 tfmod pacmx bufen latq icsys $00ac 00000000reserved $00ad 000000tcbyp0timtst $00aept7pt6pt5pt4pt3pt2pt1pt0portt $00af ddt7 ddt6 ddt5 ddt4 ddt3 ddt2 ddt1 ddt0 ddrt $00b0 0 pben 0 0 0 0 pbovi 0 pbctl $00b1000000pbovf0pbflg $00b2bit 7654321bit 0pa3h $00b3bit 7654321bit 0pa2h $00b4bit 7654321bit 0pa1h $00b5bit 7654321bit 0pa0h $00b6 bit 15 14 13 12 11 10 9 bit 8 mccnth $00b7 bit 7 6 5 4 3 2 1 bit 0 mccntl $00b8 bit 15 14 13 12 11 10 9 bit 8 tc0h $00b9bit 7654321bit 0tc0h $00ba bit 15 14 13 12 11 10 9 bit 8 tc1h $00bbbit 7654321bit 0tc1h $00bc bit 15 14 13 12 11 10 9 bit 8 tc2h $00bd bit 7 6 5 4 3 2 1 bit 0 tc2h $00be bit 15 14 13 12 11 10 9 bit 8 tc3h $00bfbit 7654321bit 0tc3h $00c0 btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 sc0bdh $00c1sbr7sbr6sbr5sbr4sbr3sbr2sbr1sbr0sc0bdl $00c2 loops woms rsrc m wake ilt pe pt sc0cr1 $00c3 tie tcie rie ilie te re rwu sbk sc0cr2 $00c4 tdre tc rdrf idle or nf fe pf sc0sr1 $00c50000000rafsc0sr2 $00c6r8t8000000sc0drh $00c7 r7/t7 r6/t6 r5/t5 r4/t4 r3/t3 r2/t2 r1/t1 r0/t0 sc0drl $00c8 btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 sc1bdh address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 5 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers register block mc68hc912dg128 ? rev 3.0 technical data motorola registers 69 $00c9sbr7sbr6sbr5sbr4sbr3sbr2sbr1sbr0sc1bdl $00ca loops woms rsrc m wake ilt pe pt sc1cr1 $00cb tie tcie rie ilie te re rwu sbk sc1cr2 $00cc tdre tc rdrf idle or nf fe pf sc1sr1 $00cd0000000rafsc1sr2 $00ce r8 t8 0 0 0000sc1drh $00cf r7/t7 r6/t6 r5/t5 r4/t4 r3/t3 r2/t2 r1/t1 r0/t0 sc1drl $00d0 spie spe swom mstr cpol cpha ssoe lsbf sp0cr1 $00d10000pupsrdpssswaispc0sp0cr2 $00d200000spr2spr1spr0sp0br $00d3spifwcol0modf0000sp0sr $00d4 0 0 0 0 0 0 0 0 reserved $00d5bit 7654321bit 0sp0dr $00d6 ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 ports $00d7 dds7 dds6 dds5 dds4 dds3 dds2 dds1 dds0 ddrs $00d8 ? $ 00df 0 0 0 0 0 0 0 0 reserved $00e0 adr7 adr6 adr5 adr4 adr3 adr2 adr1 0 ibad $00e1 0 0 ibc5 ibc4 ibc3 ibc2 ibc1 ibc0 ibfd $00e2 iben ibie ms/sl tx/rx txak rsta 0 ibswai ibcr $00e3 tcf iaas ibb ibal 0 srw ibif rxak ibsr $00e4d7d6d5d4d3d2d1d0ibdr $00e5000rdpib000pupibibpurd $00e6pib7pib6pib5pib4pib3pib2pib1pib0portib $00e7 ddrib7 ddrib6 ddrib5 ddrib4 ddrib3 ddrib2 ddrib1 ddrib0 ddrib $00e8 ? $00ef unimplemented (4) reserved $00f0 nobdml noshb 1 reserved eeswai protlck eerc eemcr $00f1 shprot 1 bprot5 bprot4 bprot3 bprot2 bprot1 bprot0 eeprot $00f2 eeodd eeven marg eecpd eecprd 0 eecpm 0 eetst $00f3 bulkp 0 0 byte row erase eelat eepgm eeprog $00f40000000lockfeelck $00f50000000bootpfeemcr $00f6 fste gadr hvt fenlv fdisvfp vtck stre mwpr feetst $00f7 0 0 0 feswai svfp eras lat enpe feectl $00f8 mt07 mt06 mt05 mt04 mt03 mt02 mt01 mt00 mtst0 $00f9 mt0f mt0e mt0d mt0c mt0b mt0a mt09 mt08 mtst1 $00fa mt17 mt16 mt15 mt14 mt13 mt12 mt11 mt10 mtst2 $00fb mt1f mt1e mt1d mt1c mt1b mt1a mt19 mt18 mtst3 address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 6 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 70 registers motorola $00fc pk7 0 0 0 pk3 pk2 pk1 pk0 portk (5) $00fd ddk7 0 0 0 ddk3 ddk2 ddk1 ddk0 ddrk (5) $00fe00000000reserved $00ff00000pix2pix1pix0ppage $0100 0 0 cswai synch tlnken slpak slprq sftres c0mcr0 $010100000loopbwupmclksrcc0mcr1 $0102 sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 c0btr0 $0103 samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 c0btr1 $0104 wupif rwrnif twrnif rerrif terrif boffif ovrif rxf c0rflg $0105 wupie rwrnie twrnie rerrie terrie boffie ovrie rxfie c0rier $0106 0 abtak2 abtak1 abtak0 0 txe2 txe1 txe0 c0tflg $0107 0 abtrq2 abtrq1 abtrq0 0 txeie2 txeie1 txeie0 c0tcr $0108 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 c0idac $0109 ? $010d unimplemented (4) reserved $010e rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 c0rxerr $010f txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 c0txerr $0110 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar0 $0111 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar1 $0112 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar2 $0113 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar3 $0114 am7 am6 am5 am4 am3 am2 am1 am0 c0idmr0 $0115 am7 am6 am5 am4 am3 am2 am1 am0 c0idmr1 $0116 am7 am6 am5 am4 am3 am2 am1 am0 c0idmr2 $0117 am7 am6 am5 am4 am3 am2 am1 am0 c0idmr3 $0118 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar4 $0119 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar5 $011a ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar6 $011b ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c0idar7 $011c am7 am6 am5 am4 am3 am2 am1 am0 c0idmr4 $011d am7 am6 am5 am4 am3 am2 am1 am0 c0idmr5 $011eam7am6am5am4am3am2am1am0c0idmr6 $011fam7am6am5am4am3am2am1am0c0idmr7 $0120 ? $013c unimplemented (4) reserved $013d000000pupcanrdpcanpctlcan0 $013e pcan7 pcan6 pcan5 pcan4 pcan3 pcan2 txcan rxcan portcan0 $013f ddcan7 ddcan6 ddcan5 ddcan4 ddcan3 ddcan2 0 0 ddrcan0 address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 7 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers register block mc68hc912dg128 ? rev 3.0 technical data motorola registers 71 $0140 ? $014f foreground receive buffer 0 rxfg0 $0150 ? $015f transmit buffer 00 tx00 $0160 ? $016f transmit buffer 01 tx01 $0170 ? $017f transmit buffer 02 tx02 $0180 ? $01df unimplemented (4) reserved $01e0 reserved atd1ctl0 $01e1 reserved atd1ctl1 $01e2 adpu affc aswai 0 0 0 ascie ascif atd1ctl2 $01e3000000frz1frz0atd1ctl3 $01e4 res10 smp1 smp0 prs4 prs3 prs2 prs1 prs0 atd1ctl4 $01e5 0 s8cm scan mult cd cc cb ca atd1ctl5 $01e6 scf 0 0 0 0 cc2 cc1 cc0 atd1stat0 $01e7 ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 atd1stat1 $01e8sar9sar8sar7sar6sar5sar4sar3sar2atd1testh $01e9 sar1 sar0 rst tstout tst3 tst2 tst1 tst0 atd1testl $01ea ? $ 01ee 0 0 0 0 0 0 0 0 reserved $01ef pad17 pad16 pad15 pad14 pad13 pad12 pad11 pad10 portad1 $01f0 bit 15 14 13 12 11 10 9 bit 8 adr10h $01f1bit 7bit 6000000adr10l $01f2 bit 15 14 13 12 11 10 9 bit 8 adr11h $01f3bit 7bit 6000000adr11l $01f4 bit 15 14 13 12 11 10 9 bit 8 adr12h $01f5bit 7bit 6000000adr12l $01f6 bit 15 14 13 12 11 10 9 bit 8 adr13h $01f7bit 7bit 6000000adr13l $01f8 bit 15 14 13 12 11 10 9 bit 8 adr14h $01f9bit 7bit 6000000adr14l $01fa bit 15 14 13 12 11 10 9 bit 8 adr15h $01fbbit 7bit 6000000adr15l $01fc bit 15 14 13 12 11 10 9 bit 8 adr16h $01fdbit 7bit 6000000adr16l $01fe bit 15 14 13 12 11 10 9 bit 8 adr17h $01ffbit 7bit 6000000adr17l address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 8 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 72 registers motorola $0200- $02ff unimplemented (4) reserved $0300 0 0 cswai synch tlnken slpak slprq sftres c1mcr0 $030100000loopbwupmclksrcc1mcr1 $0302 sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 c1btr0 $0303 samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 c1btr1 $0304 wupif rwrnif twrnif rerrif terrif boffif ovrif rxf c1rflg $0305 wupie rwrnie twrnie rerrie terrie boffie ovrie rxfie c1rier $0306 0 abtak2 abtak1 abtak0 0 txe2 txe1 txe0 c1tflg $0307 0 abtrq2 abtrq1 abtrq0 0 txeie2 txeie1 txeie0 c1tcr $0308 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 c1idac $0309 ? $030d unimplemented (4) reserved $030e rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 c1rxerr $030f txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 c1txerr $0310 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar0 $0311 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar1 $0312 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar2 $0313 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar3 $0314am7am6am5am4am3am2am1am0c1idmr0 $0315am7am6am5am4am3am2am1am0c1idmr1 $0316am7am6am5am4am3am2am1am0c1idmr2 $0317am7am6am5am4am3am2am1am0c1idmr3 $0318 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar4 $0319 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar5 $031a ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar6 address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 9 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 73 registers motorola $031b ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 c1idar7 $031cam7am6am5am4am3am2am1am0c1idmr4 $031dam7am6am5am4am3am2am1am0c1idmr5 $031e am7 am6 am5 am4 am3 am2 am1 am0 c1idmr6 $031fam7am6am5am4am3am2am1am0c1idmr7 $0320 ? $033c unimplemented (4) reserved $033d000000pupcanrdpcanpctlcan1 $033e pcan7 pcan6 pcan5 pcan4 pcan3 pcan2 txcan rxcan portcan1 $033f ddcan7 ddcan6 ddcan5 ddcan4 ddcan3 ddcan2 0 0 ddrcan1 $0340 ? $034f foreground receive buffer 1 rxfg1 $0350 ? $035f transmit buffer 10 tx10 $0360 ? $036f transmit buffer 11 tx11 $0370 ? $037f transmit buffer 12 tx12 $0380- $03ff unimplemented (4) reserved = reserved or unimplemented bits. 1. port a, port b and data direction registers ddra, ddrb are not in map in expanded and peripheral modes. 2. port e and ddre not in the map in peripheral and expanded modes with eme set. 3. registers also not in map in peripheral mode. 4. data read at these locations is undefined. 5. port k and ddrk not in the map in peripheral and expanded modes with emk set. address bit 7 6 5 4 3 2 1 bit 0 name table 4-1. register map (sheet 10 of 10) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
registers technical data mc68hc912dg128 ? rev 3.0 74 registers motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 75 technical data ? mc68hc912dg128 section 5. operating modes 5.1 contents 5.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.3 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 5.4 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.5 internal resource mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.6 memory maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 5.2 introduction eight possible operating modes determine the operating configuration of the mc68hc912dg128. each mode has an associated default memory map and external bus configuration. after reset, most system resources can be mapped to other addresses by writing to the appropriate control registers. 5.3 operating modes the operating mode out of reset is determined by the states of the bkgd, modb, and moda pins during reset. the smodn, modb, and moda bits in the mode register show current operating mode and provide limited mode switching during operation. the states of the bkgd, modb, and moda pins are latched into these bits on the rising edge of the reset signal. in expanded modes, all address space not used by internal resources is by default external memory. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 76 operating modes motorola there are two basic types of operating modes: normal modes ? some registers and bits are protected against accidental changes. special modes ? allow greater access to protected control registers and bits for special purposes such as testing and emulation. for operation above 105 ????? ?????????? ????????? ???????????? ??? ???? ??????? ????????????? ?????????? ? ??? ? ? ?? ? ? ?? ??? ?? 1 1 1 normal expanded wide addr/data addr/data 0 0 0 special single chip g.p. i/o g.p. i/o 0 0 1 special expanded narrow addr/data addr 0 1 0 special peripheral addr/data addr/data 0 1 1 special expanded wide addr/data addr/data f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes operating modes mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 77 normal single-chip mode ? there are no external address and data buses in this mode. the mcu operates as a stand- alone device and all program and data resources are on-chip. external port pins normally associated with address and data buses can be used for general-purpose i/o. normal expanded wide mode ? this is a normal mode of operation in which the expanded bus is present with a 16-bit data bus. ports a and b are used for the 16-bit multiplexed address/data bus. normal expanded narrow mode ? this is a normal mode of operation in which the expanded bus is present with an 8-bit data bus. ports a and b are used for the16-bit address bus. port a is used as the data bus, multiplexed with addresses. in this mode, 16-bit data is presented one byte at a time, the high byte followed by the low byte. the address is automatically incremented on the second cycle. 5.3.2 special operating modes there are three special operating modes that correspond to normal operating modes. these operating modes are commonly used in factory testing and system development. in addition, there is a special peripheral mode, in which an external master, such as an i.c. tester, can control the on-chip peripherals. special single-chip mode ? this mode can be used to force the mcu to active bdm mode to allow system debug through the bkgd pin. there are no external address and data buses in this mode. the mcu operates as a stand-alone device and all program and data space are on-chip. external port pins can be used for general-purpose i/o. special expanded wide mode ? this mode can be used for emulation of normal expanded wide mode and emulation of normal single-chip mode. ports a and b are used for the 16-bit multiplexed address/data bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 78 operating modes motorola special expanded narrow mode ? this mode can be used for emulation of normal expanded narrow mode. ports a and b are used for the16-bit address bus. port a is used as the data bus, multiplexed with addresses. in this mode, 16-bit data is presented one byte at a time, the high byte followed by the low byte. the address is automatically incremented on the second cycle. special peripheral mode ? the cpu is not active in this mode. an external master can control on-chip peripherals for testing purposes. it is not possible to change to or from this mode without going through reset. background debugging should not be used while the mcu is in special peripheral mode as internal bus conflicts between bdm and the external master can cause improper operation of both modes. 5.4 background debug mode background debug mode (bdm) is an auxiliary operating mode that is used for system development. bdm is implemented in on-chip hardware and provides a full set of debug operations. some bdm commands can be executed while the cpu is operating normally. other bdm commands are firmware based, and require the bdm firmware to be enabled and active for execution. bit 7654321bit 0 smodn modb moda estr ivis ebswai emk eme reset:00011011special single chip reset:00111011special exp nar reset:01011011peripheral reset:01111011special exp wide reset:10010000normal single chip reset:10110000normal exp nar reset:11110000normal exp wide mode ? mode register $000b f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 79 in special single-chip mode, bdm is enabled and active immediately out of reset. bdm is available in all other operating modes, but must be enabled before it can be activated. bdm should not be used in special peripheral mode because of potential bus conflicts. once enabled, background mode can be made active by a serial command sent via the bkgd pin or execution of a cpu12 bgnd instruction. while background mode is active, the cpu can interpret special debugging commands, and read and write cpu registers, peripheral registers, and locations in memory. while bdm is active, the cpu executes code located in a small on-chip rom mapped to addresses $ff20 to $ffff, and bdm control registers are accessible at addresses $ff00 to $ff06. the bdm rom replaces the regular system vectors while bdm is active. while bdm is active, the user memory from $ff00 to $ffff is not in the map except through serial bdm commands. the mode register controls the mcu operating mode and various configuration options. this register is not in the map in peripheral mode smodn, modb, moda ? mode select special, b and a these bits show the current operating mode and reflect the status of the bkgd, modb and moda input pins at the rising edge of reset. smodn is read anytime. may only be written in special modes (smodn = 0). the first write is ignored; bit 7654321bit 0 smodn modb moda estr ivis ebswai 0 eme reset: 00011001special single chip reset: 00111001special exp nar reset: 01011001 peripheral reset: 01111001special exp wide reset: 10010000normal single chip reset: 10110000normal exp nar reset: 11110000normal exp wide mode ? mode register $000b f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 80 operating modes motorola modb, moda may be written once in normal modes (smodn = 1). write anytime in special modes (first write is ignored) ? special peripheral and reserved modes cannot be selected. estr ? e clock stretch enable determines if the e clock behaves as a simple free-running clock or as a bus control signal that is active only for external bus cycles. estr is always one in expanded modes since it is required for address and data bus de-multiplexing and must follow stretched cycles. 0 = e never stretches (always free running). 1 = e stretches high during external access cycles and low during non-visible internal accesses (ivis = 0). normal modes: write once; special modes: write anytime. read anytime. ivis ? internal visibility this bit determines whether internal addr, data, r/w and lstrb signals can be seen on the external bus during accesses to internal locations. in special narrow mode if this bit is set and an internal access occurs the data will appear wide on ports a and b. this serves the same function as the emd bit of the non-multiplexed versions of the hc12 and allows for emulation. visibility is not available when the part is operating in a single-chip mode. 0 = no visibility of internal bus operations on external bus. 1 = internal bus operations are visible on external bus. normal modes: write once; special modes: write anytime except the first time. read anytime. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 81 ebswai ? external bus module stop in wait control this bit controls access to the external bus interface when in wait mode. the module will delay before shutting down in wait mode to allow for final bus activity to complete. 0 = external bus and registers continue functioning during wait mode. 1 = external bus is shut down during wait mode. normal modes: write anytime; special modes: write never. read anytime. emk ? emulate port k in single-chip mode portk and ddrk are always in the map regardless of the state of this bit. 0 = port k and ddrk registers are in the memory map. memory expansion emulation is disabled and all pins are general purpose i/o. 1 = in expanded or peripheral mode, portk and ddrk are removed from the internal memory map. removing these registers from the map allows the user to emulate the function of these registers externally. normal modes: write once; special modes: write anytime except the first time. read anytime. 5.5 internal resource mapping the internal register block, ram, and eeprom have default locations within the 64k byte standard address space but may be reassigned to other locations during program execution by setting bits in mapping registers initrg, initrm, and initee. during normal operating modes these registers can be written once. it is advisable to explicitly establish these resource locations during the initialization phase of program execution, even if default values are chosen, in order to protect the registers from inadvertent modification later. writes to the mapping registers go into effect between the cycle that follows the write and the cycle after that. to assure that there are no f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 82 operating modes motorola unintended operations, a write to one of these registers should be followed with a nop instruction. if conflicts occur when mapping resources, the register block will take precedence over the other resources; ram or eeprom addresses occupied by the register block will not be available for storage. when active, bdm rom takes precedence over other resources, although a conflict between bdm rom and register space is not possible. the following table shows resource mapping precedence. the mc68hc912dg128 contains 128k bytes of flash eeprom nonvolatile memory which can be used to store program code or static data. this physical memory comprises four 32k byte array modules, 00fee32k, 01fee32k, 10fee32k and 11fee32k. the 32k byte array 11fee32k has a fixed location from $4000 to $7fff and $c000 to $ffff. the three 32k byte arrays 00fee32k, 01fee32k and 10fee32k are accessible through a 16k byte program page window mapped from $8000 to $bfff. the fixed 32k byte array 11fee32k can also be accessed through the program page window.. 5.5.1 register block mapping after reset the 1k byte register block resides at location $0000 but can be reassigned to any 2k byte boundary within the standard 64k byte address space. mapping of internal registers is controlled by five bits in the initrg register. the register block occupies the first 1k byte bytes of the 2k byte block. table 5-2. mapping precedence precedence resource 1 bdm rom (if active) 2 register space 3ram 4eeprom 5 on-chip flash eeprom 6 external memory f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 83 reg[15:11] ? internal register map position these bits specify the upper five bits of the 16-bit registers address. normal modes: write once; special modes: write anytime. read anytime. mmswai ? memory mapping interface stop in wait control this bit controls access to the memory mapping interface when in wait mode. normal modes: write anytime; special modes: write never. read anytime. 0 = memory mapping interface continues to function during wait mode. 1 = memory mapping interface access is shut down during wait mode. 5.5.2 ram mapping the mc68hc912dg128 has 8k bytes of fully static ram that is used for storing instructions, variables, and temporary data during program execution. since the ram is actually implemented with two 4k ram arrays, any misaligned word access between last address of first 4k ram and first address of second 4k ram will take two cycles instead of one. after reset, ram addressing begins at location $2000 but can be assigned to any 8k byte boundary within the standard 64k byte address space. mapping of internal ram is controlled by three bits in the initrm register. initrg ? initialization of internal register position register $0011 bit 7654321bit 0 reg15 reg14 reg13 reg12 reg11 0 0 mmswai reset: 0 0000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 84 operating modes motorola ram[15:13] ? internal ram map position these bits specify the upper three bits of the 16-bit ram address. normal modes: write once; special modes: write anytime. read anytime. 5.5.3 eeprom mapping the mc68hc912dg128 has 2k bytes of eeprom which is activated by the eeon bit in the initee register. mapping of internal eeprom is controlled by four bits in the initee register. after reset eeprom address space begins at location $0800 but can be mapped to any 4k byte boundary within the standard 64k byte address space. the eeprom block occupies the last 2k bytes of the 4k byte block. ee[15:12] ? internal eeprom map position these bits specify the upper four bits of the 16-bit eeprom address. normal modes: write once; special modes: write anytime. read anytime. eeon ? internal eeprom on (enabled) this bit is forced to one in single-chip modes. read or write anytime. 0 = removes the eeprom from the map. 1 = places the on-chip eeprom in the memory map at the address selected by ee[15:12]. initrm ? initialization of internal ram position register $0010 bit 7654321bit 0 ram15 ram14 ram13 0 0 0 0 0 reset: 0 0100000 initee ? initialization of internal eeprom position register $0012 bit 7654321bit 0 ee15 ee14 ee13 ee12 0 0 0 eeon reset: 0 0000001 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 85 5.5.4 flash eeprom mapping through internal memory expansion the page index register or ppage provides memory management for the mc68hc912dg128. ppage consists of three bits to indicate which physical location is active within the windows of the mc68hc912dg128. the mc68hc912dg128 has a user ? s program space window, a register space window for flash module registers, and a test program space window. the user ? s program page window consists of 16k flash eeprom bytes. one of eight pages is viewed through this window for a total of 128k accessible flash eeprom bytes. on the mc68hc912dg128, the register space window consists of a 4- byte register block. one of four pages is viewed through this window for each of the 32k flash module register blocks of mc68hc912dg128. the test mode program page window consists of 32k flash eeprom bytes. one of the four 32k byte arrays is viewed through this window for a total 128k accessible flash eeprom bytes. this window is only available in special mode for test purposes and replaces the user ? s program page window. mc68hc912dg128 has a five pin port, port k, for emulation and for general purpose i/o. three pins are used to emulate the three page indices (ppage bits) and one pin is used as an emulation chip select. when these four pins are not used for emulation they serve as general purpose i/o pins. the fifth port k pin is used as a general purpose i/o pin. 5.5.5 program space expansion there are 128k bytes of flash eeprom. with a 64k byte address space, the ppage register is needed to perform on-chip memory expansion. a program space window of 16k byte pages is located from $8000 to $bfff. three page indices are used to point to one of eight different 16k byte pages. they can be viewed as expanded addresses x16, x15 and x14. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 86 operating modes motorola * the 16k byte program space page 6 can also be accessed at a fixed location from $4000 to $7fff. the 16k byte program space page 7 can also be accessed at a fixed location from $c000 to $ffff. 5.5.6 flash register space expansion there are four 32k flash arrays for mc68hc912dg128 and each requires a 4-byte register block. a register space window is used to access one of the four 4-byte blocks and the ppage register to map each one into the window. the register space window is located from $00f4 to $00f7 after reset. only two page indices are used to point to one of the four pages of the register space. table 5-3. program space page index page index 2 (ppage bit 2) page index 1 (ppage bit 1) page index 0 (ppage bit 0) 16k program space page flash array 0 0 0 16k byte page 0 00fee32k 0 0 1 16k byte page 1 00fee32k 0 1 0 16k byte page 2 01fee32k 0 1 1 16k byte page 3 01fee32k 1 0 0 16k byte page 4 10fee32k 1 0 1 16k byte page 5 10fee32k 1 1 0 16k byte page 6* 11fee32k 1 1 1 16k byte page 7* 11fee32k table 5-4. flash register space page index page index 2 (ppage bit 2) page index 1 (ppage bit 1) page index 0 (ppage bit 0) flash register space page flash array 0 0 x $00f4-$00f7 page 0 00fee32k 0 1 x $00f4-$00f7 page 1 01fee32k 1 0 x $00f4-$00f7 page 2 10fee32k 1 1 x $00f4-$00f7 page 3 11fee32k f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 87 5.5.7 test mode program space expansion in special mode and for test purposes only, the 128k bytes of flash eeprom can be accessed through a test program space window of 32k bytes. this window replaces the user ? s program space window to be able to access an entire array. in special mode and with romtst bit set in misc register, a program space is located from $8000 to $ffff. only two page indices are used to point to one of the four 32k byte arrays. they can be viewed as expanded addresses x16 and x15. 5.5.8 page index register descriptions read and write anytime writing to the port does not change the pin states when it is configured for page index emulation output. this port is associated with the page index emulation pins. when the port is not enabled to emulate page index, the port pins are used as general-purpose i/o. port k bit 3 is always a general purpose i/o pin. this register is not in the memory map in peripheral or expanded modes when the emk control bit in mode register is set. table 5-5. test mode program space page index page index 2 (ppage bit 2) page index 1 (ppage bit 1) page index 0 (ppage bit 0) flash register space page flash array 0 0 x 32k byte array page 0 00fee32k 0 1 x 32k byte array page 1 01fee32k 1 0 x 32k byte array page 2 10fee32k 1 1 x 32k byte array page 3 11fee32k portk ? port k data register $00fc bit 7 6 5 4 3 2 1 bit 0 port pk7 0 0 0 pk3 pk2 pk1 pk0 emulation ecs 0 0 0 - pix2 pix1 pix0 reset: - 0 0 0 - - - - f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 88 operating modes motorola when selected as inputs, these pins can be configured to be high impedance or pulled up. ecs ? emulation chip select of selected program space when this signal is active low it indicates that the program space is accessed. this also applies to test mode program space. an access is made if an address is in the program space window and either the flash or external memory is accessed. the ecs timing is e clock high and can be stretched when accessing external memory depending on the extr0 and extr1 bits in the misc register. the ecs signal is only active when the emk bit is set. pix[2:0] ? the content of the ppage register emulated externally. this content indicates which flash module register space is in the memory map and which 16k byte flash memory is in the program space. in special mode and with romtst bit set, the content of the page index register indicates which 32k byte flash array is in the test program space. read and write: anytime. this register determines the primary direction for each port k pin configured as general-purpose i/o. 0 = associated pin is a high-impedance input. 1 = associated pin is an output. this register is not in the map in peripheral or expanded modes when the emk control bit is set. ddrk ? port k data direction register $00fd bit 7 6 5 4 3 2 1 bit 0 ddk7 0 0 0 ddk3 ddk2 ddk1 ddk0 reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 89 read and write: anytime. this register determines the active page viewed through mc68hc912dg128 windows. call and rtc instructions have a special single wire mechanism to read and write this register without using an address bus. 5.5.9 miscellaneous system control register additional mapping and external resource controls are available. to use external resources the part must be operated in one of the expanded modes. normal modes: write once; special modes: write anytime. read anytime. romtst ? flash eeprom test mode in normal modes, this bit is forced to zero. 0 = 16k window for flash memory is located from $8000 ? $bfff 1 = 32k window for flash memory is located from $8000 ? $ffff ppage ? (program) page index register $00ff bit 7 6 5 4 3 2 1 bit 0 0 0 0 0 0 pix2 pix1 pix0 reset: 0 0 0 0 0 0 0 0 misc ? miscellaneous mapping control register $0013 bit 7654321bit 0mode romtst ndrf rfstr1 rfstr0 exstr1 exstr0 romhm romon reset: 0 0 0 0 1 1 0 0 exp mode reset: 0 0 0 0 1 1 0 1 peripheral or sc mode f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 90 operating modes motorola ndrf ? narrow data bus for register-following map space this bit enables a narrow bus feature for the 1k 512 byte register- following map. this is useful for accessing 8-bit peripherals and allows 8-bit and 16-bit external memory devices to be mixed in a system. in expanded narrow (eight bit) modes, single chip modes, and peripheral mode, this bit has no effect. 0 = makes register-following map space act as a full 16 bit data bus. 1 = makes the register-following map space act the same as an 8 bit only external data bus (data only goes through port a externally). the register-following space is mapped from $0400 to $07ff after reset, which is next to the register map. if the registers are moved this space follows. rfstr1, rfstr0 ? register following stretch this two bit field determines the amount of clock stretch on accesses to the 1k byte register following map. it is valid regardless of the state of the ndrf bit. in single chip and peripheral modes this bit has no meaning or effect. table 5-6. rfstr stretch bit definition rfstr1 rfstr0 number of e clocks stretched 00 0 01 1 10 2 11 3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes internal resource mapping mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 91 exstr1, exstr0 ? external access stretch this two bit field determines the amount of clock stretch on accesses to the external address space. in single chip and peripheral modes this bit has no meaning or effect. romhm ? flash eeprom only in second half of map this bit has no meaning if romon bit is clear. 0 = the 16k byte of fixed flash eeprom in location $4000 ? $7fff can be accessed. 1 = disables direct access to 16k byte flash eeprom from $4000 ? $7fff in the memory map. the physical location of this16k byte flash can still be accessed through the program page window. in special mode, with romtst bit set, this bit will allow overlap of the four 32k flash eeprom arrays and overlap the four 4-byte flash register space in the same map space to be able to program all arrays at the same time. 0 = the four 32k flash arrays are accessed with four pages for each. 1 = the four 32k flash arrays coincide in the same space and are selected at the same time for programming. caution: bit must be cleared before reading any of the arrays or registers. romon ? enable flash eeprom these bits are used to enable the flash eeprom 0 = disables flash eeprom in the memory map. 1 = enables flash eeprom in the memory map. table 5-7. exstr stretch bit definition exstr1 exstr0 number of e clocks stretched 00 0 01 1 10 2 11 3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 92 operating modes motorola 5.5.10 mapping test registers these registers are used for testing the mapping logic. they can only be read and after each read they get cleared. a write to each register will have no effect. mtst0 ? mapping test register 0 $00f8 bit 7654321bit 0 mt07 mt06 mt05 mt04 mt03 mt02 mt01 mt00 reset: 00000000 mtst1 ? mapping test register 1 $00f9 bit 7654321bit 0 mt0f mt0e mt0d mt0c mt0b mt0a mt09 mt08 reset: 00000000 mtst2 ? mapping test register 2 $00fa bit 7654321bit 0 mt17 mt16 mt15 mt14 mt13 mt12 mt11 mt10 reset: 0 0 0 00000 mtst3 ? mapping test register 3 $00fb bit 7654321bit 0 mt1f mt1e mt1d mt1c mt1b mt1a mt19 mt18 reset: 0 0 0 00000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes memory maps mc68hc912dg128 ? rev 3.0 technical data motorola operating modes 93 5.6 memory maps the following diagrams illustrate the memory map for each mode of operation immediately after reset . figure 5-1. memory map after reset the following diagram illustrates the memory paging scheme. $03ff registers (mappable to any 2k space) 8k bytes ram (mappable to any 8k space) expanded normal single chip special single chip $0000 $3fff $2000 2k bytes eeprom (mappable to any 4k space) $0fff $0800 vectors vectors vectors bdm (if active) $ffff $ff00 16k page window eight 16k flash eeprom pages $bfff $8000 ext $a000 - $bfff protected boot at odd programing pages $0000 $2000 $0800 $1000 $8000 $ff00 $ffff $0400 16k fixed flash eeprom $4000 16k fixed flash eeprom $ffff $c000 $e000 - $ffff protected boot $4000 $c000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
operating modes technical data mc68hc912dg128 ? rev 3.0 94 operating modes motorola figure 5-2. memory paging * this 32k flash accessible as pages 6 & 7 and as unpaged $4000 - $7fff & $c000 - $ffff 0 normal single chip 00 flash 32k vectors one 16k page accessible at a time (selected by ppage value = 0 to 7) $0000 $2000 $0800 $1000 $8000 $ff00 $ffff $0400 16k flash (unpaged) $4000 $c000 1234567 6 7 01 flash 32k 10 flash 32k 11 flash 32k * 16k flash (unpaged) 16k flash (paged) (8k boot) (8k boot) (8k boot) (8k boot) (8k boot) $e000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 95 technical data ? mc68hc912dg128 section 6. bus control and input/output 6.1 contents 6.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.3 detecting access type from external signals . . . . . . . . . . . . .95 6.4 registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.2 introduction internally the mc68hc912dg128 has full 16-bit data paths, but depending upon the operating mode and control registers, the external multiplexed bus may be 8 or 16 bits. there are cases where 8-bit and 16-bit accesses can appear on adjacent cycles using the lstrb signal to indicate 8- or 16-bit data. it is possible to have a mix of 8 and 16 bit peripherals attached to the external multiplexed bus, using the ndrf bit in the misc register while in expanded wide modes. 6.3 detecting access type from external signals the external signals lstrb , r/w , and a0 can be used to determine the type of bus access that is taking place. accesses to the internal ram module are the only type of access that produce lstrb =a0=1, because the internal ram is specifically designed to allow misaligned 16-bit accesses in a single cycle. in these cases the data for the address f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 96 bus control and input/output motorola that was accessed is on the low half of the data bus and the data for address + 1 is on the high half of the data bus. 6.4 registers not all registers are visible in the mc68hc912dg128 memory map under certain conditions. in special peripheral mode the first 16 registers associated with bus expansion are removed from the memory map. in expanded modes, some or all of port a, port b, and port e are used for expansion buses and control signals. in order to allow emulation of the single-chip functions of these ports, some of these registers must be rebuilt in an external port replacement unit. in any expanded mode, port a, and port b, are used for address and data lines so registers for these ports, as well as the data direction registers for these ports, are removed from the on-chip memory map and become external accesses. in any expanded mode, port e pins may be needed for bus control (e.g., eclk, r/w ). to regain the single-chip functions of port e, the emulate port e (eme) control bit in the mode register may be set. in this special case of expanded mode and eme set, porte and ddre registers are removed from the on-chip memory map and become external accesses so port e may be rebuilt externally. figure 6-1. access type vs. bus control pins lstrb a0 r/w type of access 1 0 1 8-bit read of an even address 0 1 1 8-bit read of an odd address 1 0 0 8-bit write of an even address 0 1 0 8-bit write of an odd address 0 0 1 16-bit read of an even address 111 16-bit read of an odd address (low/high data swapped) 0 0 0 16-bit write to an even address 110 16-bit write to an even address (low/high data swapped) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output registers mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 97 bits pa[7:0] are associated respectively with addresses addr[15:8], data[15:8] and data[7:0], in narrow mode. when this port is not used for external addresses such as in single-chip mode, these pins can be used as general-purpose i/o. ddra determines the primary direction of each pin. this register is not in the on-chip map in expanded and peripheral modes. read and write anytime. this register determines the primary direction for each port a pin when functioning as a general-purpose i/o port. ddra is not in the on-chip map in expanded and peripheral modes. read and write anytime. 0 = associated pin is a high-impedance input 1 = associated pin is an output bit 7654321bit 0 single chip pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 reset: ???????? expanded & periph: addr15/ data15 addr14/ data14 addr13/ data13 addr12/ data12 addr11/ data11 addr10/ data10 addr9/ data9 addr8/ data8 expanded narrow addr15/ data15/ data7 addr14/ data14/ data6 addr13/ data13/ data5 addr12/ data12/ data4 addr11/ data11/ data3 addr10/ data10/ data2 addr9/ data9/ data1 addr8/ data8/ data0 porta ? port a register $0000 bit 7654321bit 0 dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 reset: 0 0 0 0 0 0 0 0 ddra ? port a data direction register $0002 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 98 bus control and input/output motorola bits pb[7:0] are associated with addresses addr[7:0] and data[7:0] (except in narrow mode) respectively. when this port is not used for external addresses such as in single-chip mode, these pins can be used as general-purpose i/o. ddrb determines the primary direction of each pin. this register is not in the on-chip map in expanded and peripheral modes. read and write anytime. this register determines the primary direction for each port b pin when functioning as a general-purpose i/o port. ddrb is not in the on-chip map in expanded and peripheral modes. read and write anytime. 0 = associated pin is a high-impedance input 1 = associated pin is an output bit 7654321bit 0 single chip pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 reset: ???????? expanded & periph: addr7/ data7 addr6/ data6 addr5/ data5 addr4/ data4 addr3/ data3 addr2/ data2 addr1/ data1 addr0/ data0 expanded narrow addr7 addr6 addr5 addr4 addr3 addr2 addr1 addr0 portb ? port b register $0001 bit 7654321bit 0 ddb7 ddb6 ddb5 ddb4 ddb3 ddb2 ddb1 ddb0 reset: 0 0 0 0 0 0 0 0 ddrb ? port b data direction register $0003 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output registers mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 99 this register is associated with external bus control signals and interrupt inputs, including data bus enable (dbe ), mode select (modb/ipipe1, moda/ipipe0), e clock, size (lstrb ), read/write (r/w ), irq , and xirq . when the associated pin is not used for one of these specific functions, the pin can be used as general-purpose i/o. the port e assignment register (pear) selects the function of each pin. ddre determines the primary direction of each port e pin when configured to be general-purpose i/o. some of these pins have software selectable pull-ups (dbe , lstrb , r/w , irq , and xirq ). a single control bit enables the pull-ups for all these pins which are configured as inputs. this register is not in the map in peripheral mode or expanded modes when the eme bit is set. read and write anytime. bit 7654321bit 0 pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 reset: ???????? alt. pin function dbe or eclk or cal modb or ipipe1 or cgmtst moda or ipipe0 eclk lstrb or taglo r/w irq xirq porte ? port e register $0008 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 100 bus control and input/output motorola this register determines the primary direction for each port e pin configured as general-purpose i/o. 0 = associated pin is a high-impedance input 1 = associated pin is an output pe[1:0] are associated with xirq and irq and cannot be configured as outputs. these pins can be read regardless of whether the alternate interrupt functions are enabled. this register is not in the map in peripheral mode and expanded modes while the eme control bit is set. read and write anytime. the pear register is used to choose between the general-purpose i/o functions and the alternate bus control functions of port e. when an bit 7654321bit 0 dde7 dde6 dde5 dde4 dde3 dde2 0 0 reset: 0 0 000000 ddre ? port e data direction register $0009 bit 7654321bit 0 ndbe cgmte pipoe neclk lstre rdwe cale dbene reset: 0 0 0 0 0 0 0 0 normal expanded reset: 0 0 1 0 1 1 0 0 special expanded reset: 1 1 0 1 0 0 0 0 peripheral reset: 1 0 0 1 0 0 0 0 normal single chip reset: 0 0 1 0 1 1 0 0 special single chip pear ? port e assignment register $000a f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output registers mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 101 alternate control function is selected, the associated ddre bits are overridden. the reset condition of this register depends on the mode of operation because bus -control signals are needed immediately after reset in some modes. in normal single-chip mode, no external bus control signals are needed so all of port e is configured for general-purpose i/o. in normal expanded modes, the reset vector is located in external memory. the dbe and e clock are required for de-multiplexing address and data, but lstrb and r/w are only needed by the system when there are external writable resources. therefore in normal expanded modes, only the dbe and e clock are configured for their alternate bus control functions and the other bits of port e are configured for general- purpose i/o. if the normal expanded system needs any other bus-control signals, pear would need to be written before any access that needed the additional signals. in special expanded modes, dbe , ipipe1, ipipe0, e, lstrb , and r/w are configured as bus-control signals. in special single chip modes, dbe , ipipe1, ipipe0, e, lstrb , r/w, and cale are configured as bus-control signals. in peripheral mode, the pear register is not accessible for reads or writes. however, the cgmte control bit is reset to one to configure pe6 as a test output from the pll module. ndbe ? no data bus enable normal: write once; special: write anytime except the first. read anytime. 0 = pe7 is used for dbe , external control of data enable on memories, or inverted e clock. 1 = pe7 is the cal function if cale bit is set in pear register or general-purpose i/o. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 102 bus control and input/output motorola ndbe controls the use of the dbe pin of port e. the ndbe bit has no effect in single chip or peripheral modes. the associated pin will default to the cal function if the cale bit is set in pear register or otherwise to an i/o. cgmte ? clock generator module testing enable normal: write never; special: write anytime except the first. read anytime. 0 = pe6 is general-purpose i/o or pipe output. 1 = pe6 is a test signal output from the cgm module (no effect in single chip or normal expanded modes). pipoe = 1 overrides this function and forces pe6 to be a pipe status output signal. pipoe ? pipe status signal output enable normal: write once; special: write anytime except the first time. read anytime. 0 = pe[6:5] are general-purpose i/o (if cgmte = 1, pe6 is a test output signal from the cgm module). 1 = pe[6:5] are outputs and indicate the state of the instruction queue (only effective in expanded modes). neclk ? no external e clock normal single chip: write once; special single chip: write anytime; all other modes: write never. read anytime. in peripheral mode, e is an input and in all other modes, e is an output. 0 = pe4 is the external e-clock pin subject to the following limitation: in single-chip modes, to get an e clock output signal, it is necessary to have estr = 0 in addition to neclk = 0. a 16-bit write to pear and mode registers can configure all three bits in one operation. 1 = pe4 is a general-purpose i/o pin. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output registers mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 103 lstre ? low strobe (lstrb ) enable normal: write once; special: write anytime except the first time. read anytime. this bit has no effect in single-chip modes or normal expanded narrow mode. 0 = pe3 is a general-purpose i/o pin. 1 = pe3 is configured as the lstrb bus-control output, provided the mcu is not in single chip or normal expanded narrow modes. lstrb is used during external writes. after reset in normal expanded mode, lstrb is disabled. if needed, it should be enabled before external writes. external reads do not normally need lstrb because all 16 data bits can be driven even if the mcu only needs 8 bits of data. in normal expanded narrow mode this pin is reset to an output driving high allowing the pin to be an output while in and immediately after reset. taglo is a shared function of the pe3/lstrb pin. in special expanded modes with lstre set and the bdm tagging on, a zero at the falling edge of e tags the instruction word low byte being read into the instruction queue. rdwe ? read/write enable normal: write once; special: write anytime except the first time. read anytime. this bit has no effect in single-chip modes. 0 = pe2 is a general-purpose i/o pin. 1 = pe2 is configured as the r/w pin. in single chip modes, rdwe has no effect and pe2 is a general-purpose i/o pin. r/w is used for external writes. after reset in normal expanded mode, it is disabled. if needed it should be enabled before any external writes. cale ? calibration reference enable read and write anytime. 0 = calibration reference is disabled and pe7 is general-purpose i/o in single chip or peripheral modes or if the ndbe bit is set. 1 = calibration reference is enabled on pe7 in single chip and peripheral modes or if the ndbe bit is set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 104 bus control and input/output motorola dbene ? dbe or inverted e clock on pe7 normal modes: write once. special modes: write anytime except the first; read anytime. dbene controls which signal is output on pe7 when ndbe control bit is cleared. the inverted e clock output can be used to latch the address for demultiplexing. it has the same behaviour as the e clock, except it is inverted. please note that in the case of idle expansion bus, the ? not e clock ? signal could stay high for many cycles. the dbene bit has no effect in single chip or peripheral modes and pe7 is defaulted to the cal function if the cale bit is set in the pear register or to an i/o otherwise. 0 = pe7 pin used for dbe external control of data enable on memories in expanded modes when ndbe = 0 1 = pe7 pin used for inverted e clock output in expanded modes when ndbe = 0 these bits select pull-up resistors for any pin in the corresponding port that is currently configured as an input. this register is not in the map in peripheral mode. read and write anytime. pupk ? pull-up port k enable 0 = port k pull-ups are disabled. 1 = enable pull-up devices for all port k input pins. pupj ? pull-up or pull-down port j enable 0 = port j resistive loads (pull-ups or pull-downs) are disabled. 1 = enable resistive load devices (pull-ups or pull-downs) for all port j input pins. bit 7654321bit 0 pupk pupj puph pupe 0 0 pupb pupa reset: 0 0 010000 pucr ? pull-up control register $000c f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output registers mc68hc912dg128 ? rev 3.0 technical data motorola bus control and input/output 105 puph ? pull-up or pull-down port h enable 0 = port h resistive loads (pull-ups or pull-downs) are disabled. 1 = enable resistive load devices (pull-ups or pull-downs) for all port h input pins. pupe ? pull-up port e enable 0 = port e pull-ups on pe7, pe3, pe2, pe1 and pe0 are disabled. 1 = enable pull-up devices for port e input pins pe7, pe3, pe2, pe1 and pe0. when this bit is set port e input pins 7, 3, 2, 1 and 0 have an active pull-up device. pupb ? pull-up port b enable 0 = port b pull-ups are disabled. 1 = enable pull-up devices for all port b input pins. this bit has no effect if port b is being used as part of the address/data bus (the pull-ups are inactive). pupa ? pull-up port a enable 0 = port a pull-ups are disabled. 1 = enable pull-up devices for all port a input pins. this bit has no effect if port b is being used as part of the address/data bus (the pull-ups are inactive). these bits select reduced drive for the associated port pins. this gives reduced power consumption and reduced rfi with a slight increase in transition time (depending on loading). the reduced drive function is independent of which function is being used on a particular port. this register is not in the map in peripheral mode. normal: write once; special: write anytime except the first time. read anytime. rdriv ? reduced drive of i/o lines $000d bit 7654321bit 0 rdpk rdpj rdph rdpe 0 0 rdpb rdpa reset: 0 0000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
bus control and input/output technical data mc68hc912dg128 ? rev 3.0 106 bus control and input/output motorola rdpk ? reduced drive of port k 0 = all port k output pins have full drive enabled. 1 = all port k output pins have reduced drive capability. rdpj ? reduced drive of port j 0 = all port j output pins have full drive enabled. 1 = all port j output pins have reduced drive capability. rdph ? reduced drive of port h 0 = all port h output pins have full drive enabled. 1 = all port h output pins have reduced drive capability. rdpe ? reduced drive of port e 0 = all port e output pins have full drive enabled. 1 = all port e output pins have reduced drive capability. rdpb ? reduced drive of port b 0 = all port b output pins have full drive enabled. 1 = all port b output pins have reduced drive capability. rdpa ? reduced drive of port a 0 = all port a output pins have full drive enabled. 1 = all port a output pins have reduced drive capability. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 107 technical data ? mc68hc912dg128 section 7. flash memory 7.1 contents 7.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.3 future flash eeprom support . . . . . . . . . . . . . . . . . . . . . . . 108 7.4 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 7.5 flash eeprom control block . . . . . . . . . . . . . . . . . . . . . . . . 109 7.6 flash eeprom arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.7 flash eeprom registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 7.8 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115 7.9 programming the flash eeprom . . . . . . . . . . . . . . . . . . . . . 118 7.10 erasing the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . .120 7.11 program/erase protection interlocks . . . . . . . . . . . . . . . . . . .122 7.12 stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 7.13 test mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 7.2 introduction the four flash eeprom array modules 00fee32k, 01fee32k, 10fee32k and 11fee32k for the mc68hc912dg128 serve as electrically erasable and programmable, non-volatile rom emulation memory. the modules can be used for program code that must either execute at high speed or is frequently executed, such as operating system kernels and standard subroutines, or they can be used for static data which is read frequently. the flash eeprom is ideal for program storage for single-chip applications allowing for field reprogramming. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 108 flash memory motorola 7.3 future flash eeprom support design is underway to introduce an improved 5v programming flash eeprom module based on superflash ? ????? ?????????? ?? ????? ?????????? ????? ??????????? ??????????? ???????? ?????????????? ??????????? ????????? ???????? ?????????? ????????? ? attempts to set and clear this bit will only be successful on the 68hc912dg128a where it will read as ? 1 ? or ? 0 ? as appropriate, on the 68hc912dg128a it is tied to ? 0 ? . to ensure full compatibility it is recommended that all of appendix: mc68hc912dg128a flash be reviewed. 7.4 overview the flash eeprom array is arranged in a 16-bit configuration and may be read as either bytes, aligned words or misaligned words. access time is one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. the flash eeprom module requires an external program/erase voltage (v fp ) to program or erase the flash eeprom array. the external program/erase voltage is provided to the flash eeprom module via an external v fp pin. to prevent damage to the flash array, v fp should f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory flash eeprom control block mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 109 always be within the specification as defined in table 19-10 in electrical specifications . programming is by byte or aligned word. the flash eeprom module supports bulk erase only. the flash eeprom module has hardware interlocks which protect stored data from accidental corruption. an erase- and program- protected 8-kbyte block for boot routines is located at the top of each 32- kbyte array. since boot programs must be available at all times, the only useful boot block is at $e000 ? $ffff location. all paged boot blocks can be used as protected program space if desired. 7.5 flash eeprom control block a 4-byte register block for each module controls the flash eeprom module operation. configuration information is specified and programmed independently from the contents of the flash eeprom array. at reset, the 4-byte register section starts at address $00f4 and points to the 00fee32k register block. 7.6 flash eeprom arrays after reset, a fixed 32k flash eeprom array, 11fee32k, is located from addresses $4000 to $7fff and from $c000 to $ffff. the other three 32k flash eeprom arrays 00fee32k, 01fee32k and 10fee32k, are mapped through a 16k byte program page window located from addresses $8000 to $bfff. the page window has eight 16k byte pages. the last two pages also map the physical location of the fixed 32k flash eeprom array 11fee32k. in expanded modes, the flash eeprom arrays are turned off. see operating modes . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 110 flash memory motorola 7.7 flash eeprom registers each 32k byte flash eeprom module has a set of registers. the register space $00f4-$00f7 is in a register space window of four pages. each register page of four bytes maps the register space for each flash module and each page is selected by the ppage register. see operating modes . in normal modes the lock bit can only be written once after reset. lock ? lock register bit 0 = enable write to feemcr register 1 = disable write to feemcr register this register controls the operation of the flash eeprom array. bootp cannot be changed when the lock control bit in the feelck register is set or if enpe in the feectl register is set. bootp ? boot protect the boot blocks are located at $e000 ? $ffff and $a000 ? $bfff for odd program pages for each flash eeprom module. since boot programs must be available at all times, the only useful boot block is at $e000 ? $ffff location. all paged boot blocks can be used as protected program space if desired. 0 = enable erase and program of 8k byte boot block 1 = disable erase and program of 8k byte boot block feelck ? flash eeprom lock control register $00f4 bit 7 6 5 4 3 2 1 bit 0 0 0 0 0 0 0 0 lock reset: 0 0 0 0 0 0 0 0 feemcr ? flash eeprom module configuration register $00f5 bit 7 6 5 4 3 2 1 bit 0 0 0 0 0 0 0 0 bootp reset: 0 0 0 0 0 0 0 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory flash eeprom registers mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 111 in normal mode, writes to feetst control bits have no effect and always read zero. the flash eeprom module cannot be placed in test mode inadvertently during normal operation. fste ? stress test enable 0 = disables the gate/drain stress circuitry 1 = enables the gate/drain stress circuitry gadr ? gate/drain stress test select 0 = selects the drain stress circuitry 1 = selects the gate stress circuitry hvt ? stress test high voltage status 0 = high voltage not present during stress test 1 = high voltage present during stress test fenlv ? enable low voltage 0 = disables low voltage transistor in current reference circuit 1 = enables low voltage transistor in current reference circuit fdisvfp ? disable status v fp voltage lock when the v fp pin is below normal programming voltage the flash module will not allow writing to the lat bit; the user cannot erase or program the flash module. the fdisvfp control bit enables writing to the lat bit regardless of the voltage on the v fp pin. 0 = enable the automatic lock mechanism if v fp is low 1 = disable the automatic lock mechanism if v fp is low feetst ? flash eeprom module test register $00f6 bit 7 6 5 4 3 2 1 bit 0 fste gadr hvt fenlv fdisvfp vtck stre mwpr reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 112 flash memory motorola vtck ? v t check test enable when vtck is set, the flash eeprom module uses the v fp pin to control the control gate voltage; the sense amp time-out path is disabled. this allows for indirect measurements of the bit cells program and erase threshold. if v fp < v zbrk (breakdown voltage) the control gate will equal the v fp voltage. if v fp > v zbrk the control gate will be regulated by the following equation: vcontrol gate = v zbrk + ?? ? ? ? ? ?? ?? ?? ?? ? ? spare test row enable the spare test row consists of one flash eeprom array row. the reserved word at location 31 contains production test information which must be maintained through several erase cycles. when stre is set, the decoding for the spare test row overrides the address lines which normally select the other rows in the array. 0 = lib accesses are to the flash eeprom array 1 = spare test row in array enabled if smod is active mwpr ? multiple word programming used primarily for testing, if mwpr = 1, the two least-significant address lines addr[1:0] will be ignored when programming a flash eeprom location. the word location addressed if addr[1:0] = 00, along with the word location addressed if addr[1:0] = 10, will both be programmed with the same word data from the programming latches. this bit should not be changed during programming. 0 = multiple word programming disabled 1 = program 32 bits of data f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory flash eeprom registers mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 113 this register controls the programming and erasure of the flash eeprom. feeswai ? flash eeprom stop in wait control 0 = do not halt flash eeprom clock when the part is in wait mode. 1 = halt flash eeprom clock when the part is in wait mode. note: the feeswai bit cannot be asserted if the interrupt vector resides in the flash eeprom array. svfp ? status v fp voltage svfp is a read only bit. 0 = voltage of v fp pin is below normal programming voltage levels 1 = voltage of v fp pin is above normal programming voltage levels eras ? erase control this bit can be read anytime or written when enpe = 0. when set, all locations in the array will be erased at the same time. the boot block will be erased only if bootp = 0. this bit also affects the result of attempted array reads. see table 7-1 for more information. status of eras cannot change if enpe is set. 0 = flash eeprom configured for programming 1 = flash eeprom configured for erasure lat ? latch control this bit can be read anytime or written when enpe = 0. when set, the flash eeprom is configured for programming or erasure and, upon the next valid write to the array, the address and data will be latched for the programming sequence. see table 7-1 for the effects of lat on array reads. a high voltage detect circuit on the v fp pin will prevent assertion of the lat bit when the programming voltage is at normal levels. feectl ? flash eeprom control register $00f7 bit 7 6 5 4 3 2 1 bit 0 0 0 0 feeswai svfp eras lat enpe reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 114 flash memory motorola 0 = programming latches disabled 1 = programming latches enabled enpe ? enable programming/erase 0 = disables program/erase voltage to flash eeprom 1 = applies program/erase voltage to flash eeprom enpe can be asserted only after lat has been asserted and a write to the data and address latches has occurred. if an attempt is made to assert enpe when lat is negated, or if the latches have not been written to after lat was asserted, enpe will remain negated after the write cycle is complete. the lat, eras and bootp bits cannot be changed when enpe is asserted. a write to feectl may only affect the state of enpe. attempts to read a flash eeprom array location in the flash eeprom module while enpe is asserted will not return the data addressed. see table 7-1 for more information. flash eeprom module control registers may be read or written while enpe is asserted. if enpe is asserted and lat is negated on the same write access, no programming or erasure will be performed. table 7-1. effects of enpe, lat and eras on array reads enpe lat eras result of read 00 ? normal read of location addressed 0 1 0 read of location being programmed 0 1 1 normal read of location addressed 1 ?? read cycle is ignored f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory operation mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 115 7.8 operation the flash eeprom can contain program and data. on reset, it can operate as a bootstrap memory to provide the cpu with internal initialization information during the reset sequence. 7.8.1 bootstrap operation single-chip mode after reset, the cpu controlling the system will begin booting up by fetching the first program address from address $fffe. 7.8.2 normal operation the flash eeprom allows a byte or aligned word read/write in one bus cycle. misaligned word read/write require an additional bus cycle. the flash eeprom array responds to read operations only. write operations are ignored. 7.8.3 program/erase operation an unprogrammed flash eeprom bit has a logic state of one. a bit must be programmed to change its state from one to zero. erasing a bit returns it to a logic one. the flash eeprom has a minimum program/erase life of 100 cycles. programming or erasing the flash eeprom is accomplished by a series of control register writes and a write to a set of programming latches. programming is restricted to a single byte or aligned word at a time as determined by internal signal sz8 and addr[0]. the flash eeprom must first be completely erased prior to programming final data values. it is possible to program a location in the flash eeprom without erasing the entire array if the new value does not require the changing of bit values from zero to one. read/write accesses during program/erase ? during program or erase operations, read and write accesses may be different from those during normal operation and are affected by the state of the control bits in the flash eeprom control register (feectl). the next write to any f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 116 flash memory motorola valid address to the array after lat is set will cause the address and data to be latched into the programming latches. once the address and data are latched, write accesses to the array will be ignored while lat is set. writes to the control registers will occur normally. program/erase verification ? when programming or erasing the flash eeprom array, a special verification method is required to ensure that the program/erase process is reliable, and also to provide the longest possible life expectancy. this method requires stopping the program/erase sequence at periods of t ppulse (t epulse for erasing) to determine if the flash eeprom is programmed/erased. after the location reaches the proper value, it must continue to be programmed/erased with additional margin pulses to ensure that it will remain programmed/erased. failure to provide the margin pulses could lead to corrupted or unreliable data. program/erase sequence ? to begin a program or erase sequence the external v fp voltage must be applied and stabilized. the eras bit must be set or cleared, depending on whether a program sequence or an erase sequence is to occur. the lat bit will be set to cause any subsequent data written to a valid address within the flash eeprom to be latched into the programming address and data latches. the next flash array write cycle must be either to the location that is to be programmed if a programming sequence is being performed, or, if erasing, to any valid flash eeprom array location. writing the new address and data information to the flash eeprom is followed by assertion of enpe to turn on the program/erase voltage to program/erase the new location(s). the lat bit must be asserted and the address and data latched to allow the setting of the enpe control bit. if the data and address have not been latched, an attempt to assert enpe will be ignored and enpe will remain negated after the write cycle to feectl is completed. the lat bit must remain asserted and the eras bit must remain in its current state as long as enpe is asserted. a write to the lat bit to clear it while enpe is set will be ignored. that is, after the write cycle, lat will remain asserted. likewise, an attempt to change the state of eras will be ignored and the state of the eras bit will remain unchanged. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory operation mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 117 the programming software is responsible for all timing during a program sequence. this includes the total number of program pulses (n pp ), the length of the program pulse (t ppulse ), the program margin pulses (p m ) and the delay between turning off the high voltage and verifying the operation (t vprog ). the erase software is responsible for all timing during an erase sequence. this includes the total number of erase pulses (e m ), the length of the erase pulse (t epulse ), the erase margin pulse or pulses, and the delay between turning off the high voltage and verifying the operation (t verase ). software also controls the supply of the proper program/erase voltage to the v fp pin, and should be at the proper level before enpe is set during a program/erase sequence. a program/erase cycle should not be in progress when starting another program/erase, or while attempting to read from the array. note: although clearing enpe disables the program/erase voltage (v fp ) from the v fp pin to the array, care must be taken to ensure that v fp is at v dd whenever programming/erasing is not in progress. not doing so could damage the part. ensuring that v fp is always greater or equal to v dd can be accomplished by controlling the v fp power supply with the programming software via an output pin. alternatively, all programming and erasing can be done prior to installing the device on an application circuit board which can always connect v fp to v dd . programming can also be accomplished by plugging the board into a special programming fixture which provides program/erase voltage to the v fp pin. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 118 flash memory motorola 7.9 programming the flash eeprom programming the flash eeprom is accomplished by the following sequence. the v fp pin voltage must be at the proper level prior to executing step 4 the first time. 1. apply program/erase voltage to the v fp pin. 2. set the ppage to point to the 16k flash window to be programmed and corresponding register block. clear eras and set the lat bit in the feectl register to establish program mode and enable programming address and data latches. 3. write data to a valid address. the address and data is latched. if bootp is asserted, an attempt to program an address in the boot block will be ignored. 4. apply programming voltage by setting enpe. 5. delay for one programming pulse (t ppulse ). 6. remove programming voltage by clearing enpe. 7. delay while high voltage is turning off (t vprog ). 8. read the address location to verify that it has been programmed 9. if the location is not programmed, repeat steps 4 through 7 until the location is programmed or until the specified maximum number of program pulses has been reached (n pp ) 10. if the location is programmed, repeat the same number of pulses as required to program the location. this provides 100% program margin. 11. read the address location to verify that it remains programmed. 12. clear lat. 13. if there are more locations to program, repeat steps 2 through 10. 14. turn off v fp (reduce voltage on v fp pin to v dd ). the flowchart in figure 7-1 demonstrates the recommended programming sequence. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory programming the flash eeprom mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 119 figure 7-1. program sequence flow start prog write data to address set enpe read get next address/data no location failed location clear margin flag increment n pp counter no decrement n pp counter no yes yes yes to program turn on v fp delay for duration of program pulse (t ppulse ) clear enpe delay before verify is margin flag set? no yes no yes data correct? set margin flag data correct? n pp = 0? done? turn off v fp (t vprog ) n pp = 50? yes no done prog clear program pulse counter (n pp ) clear lat write ppage clear eras set lat f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 120 flash memory motorola 7.10 erasing the flash eeprom the following sequence demonstrates the recommended procedure for erasing any of the flash eeprom. the v fp pin voltage must be at the proper level prior to executing step 4 the first time. 1. turn on v fp (apply program/erase voltage to the v fp pin). 2. set the ppage register to point to the 32k flash array to be erased. set the lat bit and eras bit to configure the flash eeprom for erasing. 3. write to any valid address in the 32k flash array. this allows the erase voltage to be turned on; the data written and the address written are not important. the boot block will be erased only if the control bit bootp is negated. 4. apply erase voltage by setting enpe. 5. delay for a single erase pulse (t epulse ). 6. remove erase voltage by clearing enpe. 7. delay while high voltage is turning off (t verase ). 8. read the entire array to ensure that the flash eeprom is erased. 9. if all of the flash eeprom locations are not erased, repeat steps 4 through 7 until either the remaining locations are erased, or until the maximum erase pulses have been applied (n ep ) 10. if all of the flash eeprom locations are erased, repeat the same number of pulses as required to erase the array. this provides 100% erase margin. 11. read the entire array to ensure that the flash eeprom is erased. 12. clear lat. 13. turn off v fp (reduce voltage on v fp pin to v dd ). the flowchart in figure 7-2 demonstrates the recommended erase sequence. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory erasing the flash eeprom mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 121 figure 7-2. erase sequence flow start erase write ppage write to array set enpe read no array failed to erase array clear margin flag increment n ep counter decrement n ep counter no yes yes turn on v fp delay for duration of erase pulse (t epulse ) clear enpe delay before verify is margin flag set? no yes no yes array erased? set margin flag n ep = 0? turn off v fp (t verase ) n ep = 5? yes no array erased clear erase pulse counter (n ep ) clear lat array erased? set eras set lat f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 122 flash memory motorola 7.11 program/erase protection interlocks the flash eeprom program and erase mechanisms provide maximum protection from accidental programming or erasure. the voltage required to program/erase the flash eeprom (v fp ) is supplied via an external pin. if v fp is not present, no programming/erasing will occur. furthermore, the program/erase voltage will not be applied to the flash eeprom unless turned on by setting a control bit (enpe). the enpe bit may not be set unless the programming address and data latches have been written previously with a valid address. the latches may not be written unless enabled by setting a control bit (lat). the lat and enpe control bits must be written on separate writes to the control register (feectl) and must be separated by a write to the programming latches. the eras and lat bits are also protected when enpe is set. this prevents inadvertent switching between erase/program mode and also prevents the latched data and address from being changed after a program cycle has been initiated. 7.12 stop or wait mode when stop or wait commands are executed, the mcu puts the flash eeprom in stop or wait mode. in these modes the flash module will cease erasure or programming immediately. it is advised not to enter stop or wait modes when programming the flash array. caution: the flash eeprom module requires a 250nsec delay for wake-up from stop mode. if the operating bus frequency is greater than 4mhz, the flash cannot be used when recovering from stop mode when the dly bit in the intcr register is cleared. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory test mode mc68hc912dg128 ? rev 3.0 technical data motorola flash memory 123 7.13 test mode the flash eeprom has some special test functions which are only accessible when the device is in test mode. test mode is indicated to the flash eeprom module when the smod line on the lib is asserted. when smod is asserted, the special test control bits may be accessed via the lib to invoke the special test functions in the flash eeprom module. when smod is not asserted, writes to the test control bits have no effect and all bits in the test register feetst will be cleared. this ensures that flash eeprom test mode cannot be invoked inadvertently during normal operation. note that the flash eeprom module will operate normally, even if smod is asserted, until a special test function is invoked. the test mode adds additional features over normal mode which allow the tests to be performed even after the device is installed in the final product. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
flash memory technical data mc68hc912dg128 ? rev 3.0 124 flash memory motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola eeprom memory 125 technical data ? mc68hc912dg128 section 8. eeprom memory 8.1 contents 8.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 8.3 future eeprom support . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 8.4 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . . 127 8.5 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.2 introduction the mc68hc912dg128 eeprom nonvolatile memory is arranged in a 16-bit configuration. the eeprom array may be read as either bytes, aligned words or misaligned words. access times are one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. programming is by byte or aligned word. attempts to program or erase misaligned words will fail. only the lower byte will be latched and programmed or erased. programming and erasing of the user eeprom can be done in all modes. each eeprom byte or aligned word must be erased before programming. the eeprom module supports byte, aligned word, row (32 bytes) or bulk erase, all using the internal charge pump. the eeprom module has hardware interlocks which protect stored data from corruption by accidentally enabling the program/erase voltage. programming voltage is derived from the internal v dd supply with an internal charge pump. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory technical data mc68hc912dg128 ? rev 3.0 126 eeprom memory motorola 8.3 future eeprom support design is underway to introduce an improved eeprom module with integrated state machine to simplify programming and erase. this will be introduced on the 68hc912dg128a together with 5v programming flash eeprom. appendix: mc68hc912dg128a eeprom contains detailed information to assist in software planning for future eeprom compatibility and transition to the 68hc912dg128a. read, write and erase algorithms are fully compatible with the present eeprom design. the key change comes in the form of a self timed state machine for erasing & writing data. this is implemented using a pre-scaler loaded from a new word register eediv ($00ee) - located in a presently unused location this register can be written without effect, reading the location will return unpredictable data. adding 5 bytes of initialisation code to current software to load eediv (with value appropriate for the application ? s crystal frequency, extali) will help ensure compatibility. other new features for performance improvement are disabled at reset providing a compatible algorithm for modifying the eeprom. caution: other areas for consideration include: program/erase is not guaranteed in limp home mode. clock monitor cme bit must be enabled during program/erase. program/erase should not be performed with input clock frequency <250 khz. resonator/crystal frequency tolerance should be better than 2% total for < 2mhz, 3% total for >= 2mhz. successive writes to an eeprom location must be preceded by an erase cycle. to ensure full compatibility it is recommended that all of appendix: mc68hc912dg128a eeprom be reviewed. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory eeprom programmer ? s model mc68hc912dg128 ? rev 3.0 technical data motorola eeprom memory 127 8.4 eeprom programmer ? s model the eeprom module consists of two separately addressable sections. the first is a four-byte memory mapped control register block used for control, testing and configuration of the eeprom array. the second section is the eeprom array itself. at reset, the four-byte register section starts at address $00f0 and the eeprom array is located from addresses $0800 to $0fff. for information on re-mapping the register block and eeprom address space, refer to operating modes . read/write access to the memory array section can be enabled or disabled by the eeon control bit in the initee register. this feature allows the access to memory mapped resources with lower priority than the eeprom memory array. eeprom control registers can be accessed regardless of the state of eeon. any eeprom erase or program operations already in progress will not be affected by modifying eeon. using the normal eeprog control, it is possible to continue program/erase operations during wait. for lowest power consumption during wait, stop program/erase by turning off eepgm. if the stop mode is entered during programming or erasing, program/erase voltage will be automatically turned off and the rc clock (if enabled) is stopped. however, the eepgm control bit will remain set. when stop mode is terminated, the program/erase voltage will be automatically turned back on if eepgm is set. at low bus frequencies, the rc clock must be turned on for program/erase. the eeprom module contains an extra byte called shadow byte which is loaded at reset into the eemcr register. to program the shadow byte, when in special modes (smodn=0), the noshb bit in eemcr register must be cleared. normal programming routines are used to program the shadow byte which becomes accessible at address $0fc0 when noshb is cleared. at the next reset the shadow byte data is loaded into the eemcr. the shadow byte can be protected from being programmed or erased by setting the shprot bit of eeprot register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory technical data mc68hc912dg128 ? rev 3.0 128 eeprom memory motorola 8.5 eeprom control registers bits[7:4] are loaded at reset from the eeprom shadow byte. note: bits 5 and 4 are reserved for test purposes. these locations in the shadow byte should not be programmed otherwise some locations in the regular eeprom array will no longer be visible. nobdml ? background debug mode lockout disable 0 = the bdm lockout is enabled. 1 = the bdm lockout is disabled. loaded from shadow byte at reset. read anytime. write anytime in special modes (smodn=0). noshb ? shadow byte disable 0 = shadow byte enabled and accessible at address $0fc0. 1 = regular eeprom array at address $0fc0. loaded from shadow byte at reset. read anytime. write anytime in special modes (smodn=0). when noshb cleared, the regular eeprom array byte at address $0fc0 is no longer visible. the shadow byte is accessed instead for both read and program/erase operations. bulk, odd and even program/erase only apply if the shadow byte is enabled. note: bit 6 of the shadow byte should not be cleared (set to ? 0 ? ) in order to have the full eeprom array visible. eeswai ? eeprom stops in wait mode 0 = the module is not affected during wait mode 1 = the module ceases to be clocked during wait mode read and write anytime. note: the eeswai bit should be cleared if the wait mode vectors are mapped in the eeprom array. eemcr ? eeprom module configuration $00f0 bit 7654321bit 0 nobdml noshb 1 (1) 1. bits 4 and 5 have test functions and should not be programmed. 1 (1) 1 eeswai protlck eerc reset: ? (2) 2. loaded from shadow byte. ? (2) ? (2) ? (2) 1100 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory eeprom control registers mc68hc912dg128 ? rev 3.0 technical data motorola eeprom memory 129 protlck ? block protect write lock 0 = block protect bits and bulk erase protection bit can be written 1 = block protect bits are locked read anytime. write once in normal modes (smodn = 1), set and clear any time in special modes (smodn = 0). eerc ? eeprom charge pump clock 0 = system clock is used as clock source for the internal charge pump. internal rc oscillator is stopped. 1 = internal rc oscillator drives the charge pump. the rc oscillator is required when the system bus clock is lower than f prog . read and write anytime. prevents accidental writes to eeprom. read anytime. write anytime if eepgm = 0 and protlck = 0. shprot ? shadow byte protection 0 = the shadow byte can be programmed and erased. 1 = the shadow byte is protected from being programmed and erased. bprot[5:0] ? eeprom block protection 0 = associated eeprom block can be programmed and erased. 1 = associated eeprom block is protected from being programmed and erased. eeprot ? eeprom block protect $00f1 bit 7654321bit 0 shprot 1 bprot5 bprot4 bprot3 bprot2 bprot1 bprot0 reset: 1 1 1 1 1 1 1 1 table 8-1. 2k byte eeprom block protection bit name block protected block size bprot5 $0800 to $0bff 1024 bytes bprot4 $0c00 to $0dff 512 bytes bprot3 $0e00 to $0eff 256 bytes bprot2 $0f00 to $0f7f 128 bytes bprot1 $0f80 to $0fbf 64 bytes bprot0 $0fc0 to $0fff 64 bytes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory technical data mc68hc912dg128 ? rev 3.0 130 eeprom memory motorola read anytime. write in special modes only (smodn = 0). these bits are used for test purposes only. in normal modes the bits are forced to zero. eeodd ? odd row programming 0 = odd row bulk programming/erasing is disabled. 1 = bulk program/erase all odd rows. eeven ? even row programming 0 = even row bulk programming/erasing is disabled. 1 = bulk program/erase all even rows. marg ? program and erase voltage margin test enable 0 = normal operation. 1 = program and erase margin test. this bit is used to evaluate the program/erase voltage margin. eecpd ? charge pump disable 0 = charge pump is turned on during program/erase. 1 = disable charge pump. eecprd ? charge pump ramp disable known to enhance write/erase endurance of eeprom cells. 0 = charge pump is turned on progressively during program/erase. 1 = disable charge pump controlled ramp up. eecpm ? charge pump monitor enable 0 = normal operation. 1 = output the charge pump voltage on the irq /v pp pin. eetst ? eeprom test $00f2 bit 7654321bit 0 eeodd eeven marg eecpd eecprd 0 eecpm 0 reset:00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory eeprom control registers mc68hc912dg128 ? rev 3.0 technical data motorola eeprom memory 131 bulkp ? bulk erase protection 0 = eeprom can be bulk erased. 1 = eeprom is protected from being bulk or row erased. read anytime. write anytime if eepgm = 0 and protlck = 0. byte ? byte and aligned word erase 0 = bulk or row erase is enabled. 1 = one byte or one aligned word erase only. read anytime. write anytime if eepgm = 0. row ? row or bulk erase (when byte = 0) 0 = erase entire eeprom array. 1 = erase only one 32-byte row. read anytime. write anytime if eepgm = 0. byte and row have no effect when erase = 0 if byte = 1 and test mode is not enabled, only the location specified by the address written to the programming latches will be erased. the operation will be a byte or an aligned word erase depending on the size of written data. erase ? erase control 0 = eeprom configuration for programming. 1 = eeprom configuration for erasure. read anytime. write anytime if eepgm = 0. configures the eeprom for erasure or programming. eeprog ? eeprom control $00f3 bit 7654321bit 0 bulkp 0 0 byte row erase eelat eepgm reset:10000000 table 8-2. erase selection byte row block size 0 0 bulk erase entire eeprom array 0 1 row erase 32 bytes 1 0 byte or aligned word erase 1 1 byte or aligned word erase f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
eeprom memory technical data mc68hc912dg128 ? rev 3.0 132 eeprom memory motorola when test mode is not enabled and unless bulkp is set, erasure is by byte, aligned word, row or bulk. eelat ? eeprom latch control 0 = eeprom set up for normal reads. 1 = eeprom address and data bus latches set up for programming or erasing. read anytime. write anytime if eepgm = 0. byte, row, erase and eelat bits can be written simultaneously or in any sequence. eepgm ? program and erase enable 0 = disables program/erase voltage to eeprom. 1 = applies program/erase voltage to eeprom. the eepgm bit can be set only after eelat has been set. when eelat and eepgm are set simultaneously, eepgm remains clear but eelat is set. the bulkp, byte, row, erase and eelat bits cannot be changed when eepgm is set. to complete a program or erase, two successive writes to clear eepgm and eelat bits are required before reading the programmed data. a write to an eeprom location has no effect when eepgm is set. latched address and data cannot be modified during program or erase. a program or erase operation should follow the sequence below: 1. write byte, row and erase to the desired value, write eelat = 1 2. write a byte or an aligned word to an eeprom address 3. write eepgm = 1 4. wait for programming ( t prog ) or erase ( t erase ) delay time 5. write eepgm = 0 6. write eelat = 0 it is possible to program/erase more bytes or words without intermediate eeprom reads, by jumping from step 5 to step 2. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 133 technical data ? mc68hc912dg128 section 9. resets and interrupts 9.1 contents 9.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 9.3 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 9.4 latching of interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 9.5 interrupt control and priority registers . . . . . . . . . . . . . . . . . 135 9.6 interrupt test registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.7 resets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 9.8 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.9 register stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 9.10 important user information . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 9.2 introduction cpu12 exceptions include resets and interrupts. each exception has an associated 16-bit vector, which points to the memory location where the routine that handles the exception is located. vectors are stored in the upper 128 bytes of the standard 64k byte address map. the six highest vector addresses are used for resets and non-maskable interrupt sources. the remainder of the vectors are used for maskable interrupts, and all must be initialized to point to the address of the appropriate service routine. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 134 resets and interrupts motorola 9.2.1 exception priority a hardware priority hierarchy determines which reset or interrupt is serviced first when simultaneous requests are made. six sources are not maskable. the remaining sources are maskable, and any one of them can be given priority over other maskable interrupts. the priorities of the non-maskable sources are: 1. por or reset pin 2. clock monitor reset 3. cop watchdog reset 4. unimplemented instruction trap 5. software interrupt instruction (swi) 6. xirq signal (if x bit in ccr = 0) 9.3 maskable interrupts maskable interrupt sources include on-chip peripheral systems and external interrupt service requests. interrupts from these sources are recognized when the global interrupt mask bit (i) in the ccr is cleared. the default state of the i bit out of reset is one, but it can be written at any time. interrupt sources are prioritized by default but any one maskable interrupt source may be assigned the highest priority by means of the hprio register. the relative priorities of the other sources remain the same. an interrupt that is assigned highest priority is still subject to global masking by the i bit in the ccr, or by any associated local bits. interrupt vectors are not affected by priority assignment. hprio can only be written while the i bit is set (interrupts inhibited). table 9-1 lists interrupt sources and vectors in default order of priority. before masking an interrupt by clearing the corresponding local enable bit, the i-bit should be set in order to avoid an swi. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts latching of interrupts mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 135 9.4 latching of interrupts xirq is always level triggered and irq can be selected as a level triggered interrupt. these level triggered interrupt pins should only be released during the appropriate interrupt service routine. generally the interrupt service routine will handshake with the interrupting logic to release the pin. in this way, the mcu will never start the interrupt service sequence only to determine that there is no longer an interrupt source. in the event that this does occur the trap vector will be taken. if irq is selected as an edge triggered interrupt, the hold time of the level after the active edge is independent of when the interrupt is serviced. as long as the minimum hold time is met, the interrupt will be latched inside the mcu. in this case the irq edge interrupt latch is cleared automatically when the interrupt is serviced. all of the remaining interrupts are latched by the mcu with a flag bit. these interrupt flags should be cleared during an interrupt service routine or when interrupts are masked by the i bit. by doing this, the mcu will never get an unknown interrupt source and take the trap vector. table 9-1. interrupt vector map vector address interrupt source ccr mask local enable hprio value to elevate $fffe, $ffff reset none none ? $fffc, $fffd clock monitor fail reset none copctl (cme, fcme) ? $fffa, $fffb cop failure reset none cop rate selected ? $fff8, $fff9 unimplemented instruction trap none none ? $fff6, $fff7 swi none none ? $fff4, $fff5 xirq x bit none ? $fff2, $fff3 irq i bit intcr (irqen) $f2 $fff0, $fff1 real time interrupt i bit rtictl (rtie) $f0 $ffee, $ffef timer channel 0 i bit tmsk1 (c0i) $ee $ffec, $ffed timer channel 1 i bit tmsk1 (c1i) $ec $ffea, $ffeb timer channel 2 i bit tmsk1 (c2i) $ea $ffe8, $ffe9 timer channel 3 i bit tmsk1 (c3i) $e8 $ffe6, $ffe7 timer channel 4 i bit tmsk1 (c4i) $e6 $ffe4, $ffe5 timer channel 5 i bit tmsk1 (c5i) $e4 $ffe2, $ffe3 timer channel 6 i bit tmsk1 (c6i) $e2 $ffe0, $ffe1 timer channel 7 i bit tmsk1 (c7i) $e0 $ffde, $ffdf timer overflow i bit tmsk2 (toi) $de $ffdc, $ffdd pulse accumulator overflow i bit pactl (paovi) $dc f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 136 resets and interrupts motorola $ffda, $ffdb pulse accumulator input edge i bit pactl (pai) $da $ffd8, $ffd9 spi serial transfer complete i bit sp0cr1 (spie) $d8 $ffd6, $ffd7 sci 0 i bit sc0cr2 (tie, tcie, rie, ilie) $d6 $ffd4, $ffd5 sci 1 i bit sc1cr2 (tie, tcie, rie, ilie) $d4 $ffd2, $ffd3 atd0 or atd1 i bit atdxctl2 (ascie) $d2 $ffd0, $ffd1 mscan 0 wake-up i bit c0rier (wupie) $d0 $ffce, $ffcf key wake-up j or h i bit kwiej[7:0] and kwieh[7:0] $ce $ffcc, $ffcd modulus down counter underflow i bit mcctl (mczi) $cc $ffca, $ffcb pulse accumulator b overflow i bit pbctl (pbovi) $ca $ffc8, $ffc9 mscan 0 errors i bit c0rier (rwrnie, twrnie, rerrie, terrie, boffie, ovrie) $c8 $ffc6, $ffc7 mscan 0 receive i bit c0rier (rxfie) $c6 $ffc4, $ffc5 mscan 0 transmit i bit c0tcr (txeie[2:0]) $c4 $ffc2, $ffc3 cgm lock and limp home i bit pllcr (lockie, lhie) $c2 $ffc0, $ffc1 iic bus i bit ibcr (ibie) $c0 $ffbe, $ffbf mscan 1 wake-up i bit c1rier (wupie) $be $ffbc, $ffbd mscan 1 errors i bit c1rier (rwrnie, twrnie, rerrie, terrie, boffie, ovrie) $bc $ffba, $ffbb mscan 1 receive i bit c1rier (rxfie) $ba $ffb8, $ffb9 mscan 1 transmit i bit c1tcr (txeie[2:0]) $b8 $ffb6, $ffb7 reserved i bit $b6 $ff80 ? $ffb5 reserved i bit $80 ? $b4 table 9-1. interrupt vector map vector address interrupt source ccr mask local enable hprio value to elevate f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts interrupt control and priority registers mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 137 9.5 interrupt control and priority registers irqe ? irq select edge sensitive only 0 = irq configured for low-level recognition. 1 = irq configured to respond only to falling edges (on pin pe1/irq ). irqe can be read anytime and written once in normal modes. in special modes, irqe can be read anytime and written anytime, except the first write is ignored. irqen ? external irq enable the irq pin has an active pull-up. see table 3-4 . 0 = external irq pin is disconnected from interrupt logic. 1 = external irq pin is connected to interrupt logic. irqen can be read and written anytime in all modes. dly ? enable oscillator start-up delay on exit from stop the delay time of about 4096 cycles is based on the x clock rate chosen. 0 = no stabilization delay imposed on exit from stop mode. a stable external oscillator must be supplied. 1 = stabilization delay is imposed before processing resumes after stop. dly can be read anytime and written once in normal modes. in special modes, dly can be read and written anytime. intcr ? interrupt control register $001e bit 7654321bit 0 irqe irqen dly 0 0 0 0 0 reset: 0 1 1 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 138 resets and interrupts motorola write only if i mask in ccr = 1 (interrupts inhibited). read anytime. to give a maskable interrupt source highest priority, write the low byte of the vector address to the hprio register. for example, writing $f0 to hprio would assign highest maskable interrupt priority to the real-time interrupt timer ($fff0). if an un-implemented vector address or a non-i- masked vector address (value higher than $f2) is written, then irq will be the default highest priority interrupt. 9.6 interrupt test registers these registers are used in special modes for testing the interrupt logic and priority without needing to know which modules and what functions are used to generate the interrupts.each bit is used to force a specific interrupt vector by writing it to 1.bits are named with b6 through f4 to indicate vectors $ffb6 through $fff4. these bits are also used in special modes to view that an interrupt caused by a module has reached the interrupt module. these registers can only be read in special modes (read in normal mode will return $00). reading these registers at the same time as the interrupt is changing will cause an indeterminate value to be read. these registers can only be written in special mode. bit 7654321bit 0 1 psel6 psel5 psel4 psel3 psel2 psel1 0 reset:11110010 hprio ? highest priority i interrupt $001f f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts interrupt test registers mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 139 itst0 ? interrupt test register 0 $0018 bit 7654321bit 0 ite6 ite8 itea itec itee itf0 itf2 itf4 reset: 0 0 0 0 0 0 0 0 itst1 ? interrupt test register 1 $0019 bit 7654321bit 0 itd6 itd8 itda itdc itde ite0 ite2 ite4 reset: 0 0000000 itst2 ? interrupt test register 2 $001a bit 7654321bit 0 itc6 itc8 itca itcc itce itd0 itd2 itd4 reset: 0 0 0 00000 itst3 ? interrupt test register 3 $001b bit 7654321bit 0 itb6 itb8 itba itbc itbe itc0 itc2 itc4 reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 140 resets and interrupts motorola 9.7 resets there are four possible sources of reset. power-on reset (por), and external reset on the reset pin share the normal reset vector. the computer operating properly (cop) reset and the clock monitor reset each has a vector. entry into reset is asynchronous and does not require a clock but the mcu cannot sequence out of reset without a system clock. 9.7.1 power-on reset a positive transition on v dd causes a power-on reset (por). an external voltage level detector, or other external reset circuits, are the usual source of reset in a system. the por circuit only initializes internal circuitry during cold starts and cannot be used to force a reset as system voltage drops. it is important to use an external low voltage reset circuit (for example: mc34064 or mc33464) to prevent power transitions or corruption of ram or eeprom. 9.7.2 external reset the cpu distinguishes between internal and external reset conditions by sensing whether the reset pin rises to a logic one in less than nine e- clock cycles after an internal device releases reset. when a reset condition is sensed, the reset pin is driven low and a clocked reset sequence controls when the mcu can begin normal processingby an internal device for about 16 e-clock cycles, then released. in the case of a clock monitor error, a 4096 cycle oscillator start-up delay is imposed before the reset recovery sequence starts (reset is driven low throughout this 4096 cycle delay). the internal reset recovery sequence then drives reset low for 16 to 17 cycles and releases the drive to allow reset to rise. nine e-clock cycles later the reset pin it is sampled. if the pin is still held low, the cpu assumes that an external reset has occurred. if the pin is high, it indicates that the reset was initiated internally by either the cop system or the clock monitor. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts resets mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 141 to prevent a cop reset from being detected during an external reset, hold the reset pin low for at least 32 cycles. to prevent a or clock monitor reset from being detected during an external reset, hold the reset pin low for at least 4096 + 32 cycles. an external rc power-up delay circuit on the reset pin is not recommended as circuit charge time can cause the mcu to misinterpret the type of reset that has occurred. 9.7.3 cop reset the mcu includes a computer operating properly (cop) system to help protect against software failures. when cop is enabled, software must write $55 and $aa (in this order) to the coprst register in order to keep a watchdog timer from timing out. other instructions may be executed between these writes. a write of any value other than $55 or $aa or software failing to execute the sequence properly causes a cop reset to occur. in addition, windowed cop operation can be selected. in this mode, a write to the coprst register must occur in the last 25% of the selected period. a premature write will also reset the part. 9.7.4 clock monitor reset if clock frequency falls below a predetermined limit when the clock monitor is enabled, a reset occurs. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 142 resets and interrupts motorola 9.8 effects of reset when a reset occurs, mcu registers and control bits are changed to known start-up states, as follows. 9.8.1 operating mode and memory map operating mode and default memory mapping are determined by the states of the bkgd, moda, and modb pins during reset. the smodn, moda, and modb bits in the mode register reflect the status of the mode-select inputs at the rising edge of reset. operating mode and default maps can subsequently be changed according to strictly defined rules. 9.8.2 clock and watchdog control logic the cop watchdog system is enabled, with the cr[2:0] bits set for the longest duration time-out. the clock monitor is disabled. the rtif flag is cleared and automatic hardware interrupts are masked. the rate control bits are cleared, and must be initialized before the rti system is used. the dly control bit is set to specify an oscillator start-up delay upon recovery from stop mode. 9.8.3 interrupts psel is initialized in the hprio register with the value $f2, causing the external irq pin to have the highest i-bit interrupt priority. the irq pin is configured for level-sensitive operation (for wired-or systems). however, the interrupt mask bits in the cpu12 ccr are set to mask x- and i-related interrupt requests. 9.8.4 parallel i/o if the mcu comes out of reset in a single-chip mode, all ports are configured as general-purpose high-impedance inputs. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts effects of reset mc68hc912dg128 ? rev 3.0 technical data motorola resets and interrupts 143 if the mcu comes out of reset in an expanded mode, port a and port b are used for the address/data bus, and port e pins are normally used to control the external bus (operation of port e pins can be affected by the pear register). out of reset, port j, port h, port k, port ib, port p, port s, port t, port can[7:4], port ad0 and port ad1 are all configured as general-purpose inputs. 9.8.5 central processing unit after reset, the cpu fetches a vector from the appropriate address, then begins executing instructions. the stack pointer and other cpu registers are indeterminate immediately after reset. the ccr x and i interrupt mask bits are set to mask any interrupt requests. the s bit is also set to inhibit the stop instruction. 9.8.6 memory after reset, the internal register block is located from $0000 to $03ff, ram is at $2000 to $3fff, and eeprom is located at $0800 to $0fff. in single chip mode, one 32-kbyte flash module is located from $4000 to $7fff and $c000 to $ffff, and the other three 32-kbyte flash modules are accessible through the program page window located from $8000 to $bfff. the first 32-kbyte flash eeprom is also accessible through the program page window. 9.8.7 other resources the enhanced capture timer (ect), pulse width modulation timer (pwm), serial communications interfaces (sci0 and sci1), serial peripheral interface (spi), inter-ic bus (iic), motorola scalable can modules (mscan0 and mscan1) and analog-to-digital converters (atd0 and atd1) are off after reset. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 144 resets and interrupts motorola 9.9 register stacking once enabled, an interrupt request can be recognized at any time after the i bit in the ccr is cleared. when an interrupt service request is recognized, the cpu responds at the completion of the instruction being executed. interrupt latency varies according to the number of cycles required to complete the instruction. some of the longer instructions can be interrupted and will resume normally after servicing the interrupt. when the cpu begins to service an interrupt, the instruction queue is cleared, the return address is calculated, and then it and the contents of the cpu registers are stacked as shown in table 9-2 . . after the ccr is stacked, the i bit (and the x bit, if an xirq interrupt service request is pending) is set to prevent other interrupts from disrupting the interrupt service routine. the interrupt vector for the highest priority source that was pending at the beginning of the interrupt sequence is fetched, and execution continues at the referenced location. at the end of the interrupt service routine, an rti instruction restores the content of all registers from information on the stack, and normal program execution resumes. if another interrupt is pending at the end of an interrupt service routine, the register unstacking and restacking is bypassed and the vector of the interrupt is fetched. table 9-2. stacking order on entry to interrupts memory location cpu registers sp ? 2 rtn h : rtn l sp ? 4 y h : y l sp ? 6 x h : x l sp ? 8 b : a sp ? 9 ccr f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 145 resets and interrupts motorola 9.10 important user information before disabling an interrupt using a local interrupt control bit, set the i mask bit in the ccr. failing to do so may cause an swi interrupt to be fetched instead of the vector for the interrupt source that was disabled. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
resets and interrupts technical data mc68hc912dg128 ? rev 3.0 146 resets and interrupts motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola i/o ports with key wake-up 147 technical data ? mc68hc912dg128 section 10. i/o ports with key wake-up 10.1 contents 10.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 10.3 key wake-up and port registers . . . . . . . . . . . . . . . . . . . . . .148 10.4 key wake-up input filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 10.2 introduction the mc68hc912dg128 offers 16 additional i/o ports with key wake-up capability. the key wake-up feature of the mc68hc912dg128 issues an interrupt that will wake up the cpu when it is in the stop or wait mode. two ports are associated with the key wake-up function: port h and port j. port h and port j wake-ups are triggered with a rising or falling signal edge. for each pin which has an interrupt enabled, there is a path to the interrupt request signal which has no clocked devices when the part is in stop mode. this allows an active edge to bring the part out of stop. digital filtering is included to prevent pulses shorter than a specified value from waking the part from stop. an interrupt is generated when a bit in the kwifh or kwifj register and its corresponding kwieh or kwiej bit are both set. all 16 bits/pins share the same interrupt vector. key wake-ups can be used with the pins configured as inputs or outputs. default register addresses, as established after reset, are indicated in the following descriptions. for information on re-mapping the register block, refer to operating modes . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up technical data mc68hc912dg128 ? rev 3.0 148 i/o ports with key wake-up motorola 10.3 key wake-up and port registers read and write anytime. read and write anytime. data direction register j is associated with port j and designates each pin as an input or output. read and write anytime ddrj[7:0] ? data direction port j 0 = associated pin is an input 1 = associated pin is an output portj ? port j register $0028 bit 7654321bit 0 port pj7 pj6 pj5 pj4 pj3 pj2 pj1 pj0 kwu kwj7 kwj6 kwj5 kwj4 kwj3 kwj2 kwj1 kwj0 reset: - - - - - - - - bit 7654321bit 0 ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 kwu kwh7kwh6kwh5kwh4kwh3kwh2kwh1kwh0 reset: - - - ----- porth ? port h register $0029 bit 7654321bit 0 ddj7 ddj6 ddj5 ddj4 ddj3 ddj2 ddj1 ddj0 reset: 0 0 000000 ddrj ? port j data direction register $002a f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up key wake-up and port registers mc68hc912dg128 ? rev 3.0 technical data motorola i/o ports with key wake-up 149 data direction register h is associated with port h and designates each pin as an input or output. read and write anytime. ddrh[7:0] ? data direction port h 0 = associated pin is an input 1 = associated pin is an output read and write anytime. kwiej[7:0] ? key wake-up port j interrupt enables 0 = interrupt for the associated bit is disabled 1 = interrupt for the associated bit is enabled read and write anytime. kwieh[7:0] ? key wake-up port h interrupt enables 0 = interrupt for the associated bit is disabled 1 = interrupt for the associated bit is enabled bit 7654321bit 0 ddh7 ddh6 ddh5 ddh4 ddh3 ddh2 ddh1 ddh0 reset: 0 0 000000 ddrh ? port h data direction register $002b kwiej ? key wake-up port j interrupt enable register $002c bit 7654321bit 0 kwiej7 kwiej6 kwiej5 kwiej4 kwiej3 kwiej2 kwiej1 kwiej0 reset: 0 0000000 bit 7654321bit 0 kwieh7 kwieh6 kwieh5 kwieh4 kwieh3 kwieh2 kwieh1 kwieh0 reset: 0 0 000000 kwieh ? key wake-up port h interrupt enable register $002d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up technical data mc68hc912dg128 ? rev 3.0 150 i/o ports with key wake-up motorola read and write anytime. each flag is set by an active edge on its associated input pin. this could be a rising or falling edge based on the state of the kwpj register. to clear the flag, write one to the corresponding bit in kwifj. initialize this register after initializing kwpj so that illegal flags can be cleared. kwifj[7:0] ? key wake-up port j flags 0 = active edge on the associated bit has not occurred 1 = active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). read and write anytime. each flag is set by an active edge on its associated input pin. this could be a rising or falling edge based on the state of the kwph register. to clear the flag, write one to the corresponding bit in kwifh. initialize this register after initializing kwph so that illegal flags can be cleared. kwifh[7:0] ? key wake-up port h flags 0 = active edge on the associated bit has not occurred 1 = active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set) kwifj ? key wake-up port j flag register $002e bit 7654321bit 0 kwifj7 kwifj6 kwifj5 kwifj4 kwifj3 kwifj2 kwifj1 kwifj0 reset: 00000000 bit 7654321bit 0 kwifh7 kwifh6 kwifh5 kwifh4 kwifh3 kwifh2 kwifh1 kwifh0 reset: 0 0 0 0 0 0 0 0 kwifh ? key wake-up port h flag register $002f f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up key wake-up and port registers mc68hc912dg128 ? rev 3.0 technical data motorola i/o ports with key wake-up 151 read and write anytime. it is best to clear the flags after initializing this register because changing the polarity of a bit can cause the associated flag to become set. kwpj[7:0] ? key wake-up port j polarity selects 0 = falling edge on the associated port j pin sets the associated flag bit in the kwifj register and a resistive pull-up device is connected to associated port j input pin. 1 = rising edge on the associated port j pin sets the associated flag bit in the kwifj register and a resistive pull-down device is connected to associated port j input pin. read and write anytime. it is best to clear the flags after initializing this register because changing the polarity of a bit can cause the associated flag to become set. kwph[7:0] ? key wake-up port h polarity selects 0 = falling edge on the associated port h pin sets the associated flag bit in the kwifh register and a resistive pull-up device is connected to associated port h input pin. 1 = rising edge on the associated port h pin sets the associated flag bit in the kwifh register and a resistive pull-down device is connected to associated port h input pin. kwpj ? key wake-up port j polarity register $0030 bit 7654321bit 0 kwpj7 kwpj6 kwpj5 kwpj4 kwpj3 kwpj2 kwpj1 kwpj0 reset: 0 0 0 00000 kwph ? key wake-up port h polarity register $0031 bit 7654321bit 0 kwph7 kwph6 kwph5 kwph4 kwph3 kwph2 kwph1 kwph0 reset: 00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up technical data mc68hc912dg128 ? rev 3.0 152 i/o ports with key wake-up motorola 10.4 key wake-up input filter the kwu input signals are filtered by a digital filter which is active only during stop mode. the purpose of the filter is to prevent single pulses shorter than a specified value from waking the part from stop. the filter is composed of an internal oscillator and a majority voting logic. the filter oscillator starts oscillation by detecting a triggering edge on an input if the corresponding interrupt enable bit is set. the majority voting logic takes three samples of an asserted input pin at each filter oscillator period and if two samples are taken at the triggering level, the filter recognizes a valid triggering level and sets the corresponding interrupt flag. in this way, the majority voting logic rejects the short non-triggering state between two incoming triggering pulses. as the filter is shared with all kwu inputs, the filter considers any pulse coming from any input pin for which the corresponding interrupt enable bit is set. the timing specification is given for a single pulse. the time interval between the triggering edges of two following pulses should be greater than the t kwsp in order to be considered as a single pulse by the filter. if this time interval is shorter than t kwsp , the majority voting logic may treat the two consecutive pulses as a single valid pulse. the filter is shared by all the kwu pins. hence any valid triggering level on any kwu pin is seen by the filter. the timing specification applies to the input of the filter. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up key wake-up input filter mc68hc912dg128 ? rev 3.0 technical data motorola i/o ports with key wake-up 153 figure 10-1. stop key wake-up filter glitch, filtered out, no stop wake-up valid stop wake-up pulse t kwstp min. t kwstp max. minimum time interval between pulses to be recognized as single pulses t kwstp f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
i/o ports with key wake-up technical data mc68hc912dg128 ? rev 3.0 154 i/o ports with key wake-up motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 155 technical data ? mc68hc912dg128 section 11. clock functions 11.1 contents 11.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 11.3 clock sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 11.4 phase-locked loop (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . .157 11.5 acquisition and tracking modes. . . . . . . . . . . . . . . . . . . . . . .159 11.6 limp-home and fast stop recovery modes . . . . . . . . . . . . 161 11.7 system clock frequency formulas . . . . . . . . . . . . . . . . . . . . . 179 11.8 clock divider chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 11.9 computer operating properly (cop) . . . . . . . . . . . . . . . . . . .184 11.10 real-time interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11.11 clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11.12 clock function registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 11.2 introduction clock generation circuitry generates the internal and external e-clock signals as well as internal clock signals used by the cpu and on-chip peripherals. a clock monitor circuit, a computer operating properly (cop) watchdog circuit, and a periodic interrupt circuit are also incorporated into the 68hc(9)12dg128. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 156 clock functions motorola 11.3 clock sources a compatible external clock signal can be applied to the extal pin or the mcu can generate a clock signal using an on-chip oscillator circuit and an external crystal or ceramic resonator. the mcu uses several types of internal clock signals derived from the primary clock signal: txclk clocks are used by the cpu. eclk and pclk are used by the bus interfaces, spi, pwm, atd0 and atd1. mclk is either pclk or xclk, and drives on-chip modules such as sci0, sci1 and ect. xclk drives on-chip modules such as rti, cop and restart-from-stop delay time. slwclk is used as a calibration output signal. the mscan module is clocked by extali or sysclk, under control of an mscan bit. the clock monitor is clocked by extali. the bdm system is clocked by bclk or eclk, under control of a bdm bit. a slow mode clock divider is included to deliver a lower clock frequency for the sci baud rate generators, the ect timer module, and the rti and cop clocks. the slow clock bus frequencies divide the crystal frequency in a programmable range of 4 to 252, with steps of 4. figure 11-1 shows some of the timing relationships. see the clock divider chains section for further details. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions phase-locked loop (pll) mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 157 figure 11-1. internal clock relationships 11.4 phase-locked loop (pll) the phase-locked loop (pll) of the 68hc(9)12dg128 is designed for robust operation in an automotive environment. the allowed pll crystal or ceramic resonator reference of 0.5 to 8mhz is selected for the wide availability of components with good stability over the automotive temperature range. please refer to figure 11-6 in section clock divider chains for an overview of system clocks. note: when selecting a crystal, it is recommended to use one with the lowest possible frequency in order to minimise emc emissions. an oscillator design with reduced power consumption allows for slow wait operation with a typical power supply current less than a milli- ampere. the pll circuitry can be bypassed when the vddpll supply is at vss level. in this case, the pll module is powered down and the oscillator output transistor has a stronger transconductance for improved drive of higher frequency resonators (as the crystal frequency needs to be twice the maximum bus frequency). refer to figure 3-3 in pinout and signal descriptions . t1clk t2clk t3clk t4clk int eclk pclk xclk canclk f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 158 clock functions motorola figure 11-2. pll functional diagram the pll may be used to run the mcu from a different time base than the incoming crystal value. it creates an integer multiple of a reference frequency. for increased flexibility, the crystal clock can be divided by values in a range of 1 ? 8 (in unit steps) to generate the reference frequency. the pll can multiply this reference clock in a range of 1 to 64. although it is possible to set the divider to command a very high clock frequency, do not exceed the specified bus frequency limit for the mcu. if the pll is selected, it will continue to run when in wait mode resulting in more power consumption than normal. to take full advantage of the reduced power consumption of wait mode, turn off the pll before going into wait. please note that in this case the pll stabilization time applies. the pll operation is suspended in stop mode. after stop exit followed by the stabilization time, it resumes operation at the same frequency, provided the auto bit is set. a passive external loop filter must be placed on the control line (xfc pad). the filter is a second-order, low-pass filter to eliminate the vco input ripple. values of components in the diagram are dependent upon the desired vco operation. see xfc description. reduced consumption oscillator extal xtal extali pllclk reference programmable divider pdet phase detector refdv <2:0> loop programmable divider syn <5:0> cpump vco lock loop filter xfc pad up down lock detector refclk divclk slow mode programmable clock divider sldv <5:0> xclk extali 2 slwclk vddpll 2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions acquisition and tracking modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 159 11.5 acquisition and tracking modes the lock detector compares the frequencies of the vco feedback clock, divclk, and the final reference clock, refclk. therefore, the speed of the lock detector is directly proportional to the final reference frequency. the circuit determines the mode of the pll and the lock condition based on this comparison. the pll filter is manually or automatically configurable into one of two operating modes:  acquisition mode ? in acquisition mode, the filter can make large frequency corrections to the vco. this mode is used at pll start- up or when the pll has suffered a severe noise hit and the vco frequency is far off the desired frequency. this mode can also be desired in harsh environments when the leakage levels on the filter pin (xfc) can overcome the tracking currents of the pll charge pump. when in acquisition mode, the acq bit in the pll control register is clear.  tracking mode ? in tracking mode, the filter makes only small corrections to the frequency of the vco. the pll enters tracking mode when the vco frequency is nearly correct. the pll is automatically in tracking mode when not in acquisition mode or when the acq bit is set. the pll can change the bandwidth or operational mode of the loop filter manually or automatically. with an identical filtering time constant, the pll bandwidth is larger in acquisition mode than in tracking by a ratio of about 3. in automatic bandwidth control mode (auto = 1), the lock detector automatically switches between acquisition and tracking modes. automatic bandwidth control mode also is used to determine when the vco clock, pllclk, is safe to use as the source for the base clock, sysclk. if pll lock interrupt requests are enabled, the software can wait for an interrupt request and then check the lock bit. if cpu interrupts are disabled, software can poll the lock bit continuously (during pll start-up, usually) or at periodic intervals. in either case, when the lock bit is set, the pllclk clock is safe to use as the source f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 160 clock functions motorola for the base clock. see clock divider chains . if the vco is selected as the source for the base clock and the lock bit is clear, the pll has suffered a severe noise hit and the software must take appropriate action, depending on the application. the following conditions apply when the pll is in automatic bandwidth control mode:  the acq bit is a read-only indicator of the mode of the filter.  the acq bit is set when the vco frequency is within a certain tolerance, ? ???????????? ?? ? ????  the lock bit is a read-only indicator of the locked state of the pll.  the lock bit is set when the vco frequency is within a certain tolerance, ? ??????????? ??? ? ????  cpu interrupts can occur if enabled (lockie = 1) when the lock condition changes, toggling the lock bit. the pll also can operate in manual mode (auto = 0). all lock features described above are active in this mode, only the bandwidth control is disabled. manual mode is used mainly for systems operating under harsh conditions (e.g.uncoated pcbs in automotive environments). when this is the case, the pll is likely to remain in acquisition mode. the following conditions apply when in manual mode:  acq is a writable control bit that controls the mode of the filter. before turning on the pll in manual mode, the acq bit must be clear.  in case tracking is desired (acq = 1), the software must wait a given time, tacq, after turning on the pll by setting pllon in the pll control register. this is to avoid switching to tracking mode too early while the xfc voltage level is still too far away from its quiescent value corresponding to the target frequency. this operation would be very detrimental to the stabilization time. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 161 11.6 limp-home and fast stop recovery modes if the crystal frequency is not available due to a crystal failure or a long crystal start-up time, the mcu system clock can be supplied by the vco at its minimum operating frequency, f vcomin . this mode of operation is called limp-home mode and is only available when the vddpll supply voltage is at vdd level (i.e. power supply for the pll module is present). upon power-up, the ability of the system to start in limp-home mode is restricted to normal mcu modes only. the clock monitor circuit (see section clock monitor) can detect the loss of extali, the external clock input signal, regardless of whether this signal is used as the source for mcu clocks or as the pll reference clock. the clock monitor control bits, cme and fcme, are used to enable or disable external clock detection. a missing external clock may occur in the three following instances:  during normal clock operation.  at power-on reset.  in the stop exit sequence 11.6.1 clock loss during normal operation the ? no limp-home mode ? bit, nolhm, determines how the mcu responds to an external clock loss in this case. with limp home mode disabled (nolhm bit set) and the clock monitor enabled (cme or fcme bits set), on a loss of clock the mcu is reset via the clock monitor reset vector. a latch in the pll control section prevents the chip exiting reset in limp home mode (this is required as the nolhm bit gets cleared by reset). only external clock activity can bring the mcu out from this reset state. once reset has been exited, the latch is cleared and another session, with or without limp home mode enabled, can take place. this is the same behavior as standard m68hc12 circuits without pll or operation with vddpll at vss level. with limp home mode enabled (nolhm bit cleared) and the clock monitor enabled (cme or fcme bits set), on a loss of clock, the pll f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 162 clock functions motorola vco clock at its minimum frequency, f vcomin , is provided as the system clock, allowing the mcu to continue operating. the mcu is said to be operating in ? limp-home ? mode with the forced vco clock as the system clock. pllon and bcsp ( ? bus clock select pll ? ) signals are forced high and the mcs ( ? module clock select ? ) signal is forced low. the lhome flag in the pllflg register is set to indicate that the mcu is running in limp-home mode. a change of this flag sets the limp-home interrupt flag, lhif, and if enabled by the lhie bit, the limp-home mode interrupt is requested. the clock monitor is enabled irrespective of cme and fcme bit settings. module clocks to the rti & cop (xclk), bdm (bclk) and ect & sci (mclk) are forced to be pclk (at f vcomin ) and eclk is also equal to f vcomin . mscan clock select is unaffected. figure 11-3. clock loss during normal operation the clock monitor is polled each time the 13-stage free running counter reaches a count of 4096 xclk cycles i.e. mid-count, hence the clock status gets checked once every 8192 xclk cycles. when the presence of an external clock is detected, the mcu exits limp-home mode, clearing the lhome flag and setting the limp-home interrupt flag. upon leaving limp-home mode, bcsp and mcs signals are restored to their 0 --> 4096 limp-home (clocked by xclk) bcsp restore bcsp sysclk pllclk (limp-home) restore pllclk or extali extali 13-stage counter clock monitor fail 0 --> 4096 ab f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 163 values before the clock loss. all clocks return to their normal settings and clock monitor control is returned to the cme & fcme bits. if auto and bcsp bits were set before the clock loss (selecting the pll to provide a system clock) the sysclk ramps-up and the pll locks at the previously selected frequency. to prevent pll operation when the external clock frequency comes back, software should clear the bcsp bit while running in limp-home mode. the two shaded regions a and b in figure 11-3 present a of code run away due to incorrect clocks on sysclk if the mcu is clocked by extali and the pll is not used. in region a , there is a delay between the loss of clock and its detection by the clock monitor. when the extali clock signal is disturbed, the clock generation circuitry may receive an out of spec signal and drive the cpu with irregular clocks. this may lead to code runaway. in region b , as the 13-stage counter is free running, the count of 4096 may be reached when the amplitude of the extali clock has not stabilized. in this case, an improper extali is sent to the clock generation circuitry when limp-home mode is exited. this may also cause code runaway. if the mcu is clocked by the pll, the risk of code runaway is very low, but it can still occur under certain conditions due to irregular clocks from the clock source appearing on the sysclk. caution: the cop watch dog should always be enabled in order to reset the mcu in case of a code runaway situation. note: it is always advisable to take additional precautions within the application software to trap such situations. 11.6.2 no clock at power-on reset the voltage level on vddpll determines how the mcu responds to an external clock loss in this case. with the vddpll supply voltage at vdd level, any reset sets the clock monitor enable bit (cme) and the pllon bit and clears the nolhm bit. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 164 clock functions motorola therefore, if the mcu is powered up without an external clock, limp- home mode is entered provided the mcu is in a normal mode of operation. figure 11-4. no clock at power-on reset vdd power-on detector clock monitor fail extali 13-stage counter internal reset 0 --> 4096 limp-home (clocked by xclk) bcsp reset: bcsp = 0 sysclk pllclk (l.h.) extali sysclk pllclk (software check of limp-home flag) extali (slow extali) 0 --> 4096 (slow extali) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 165 during this power up sequence, after the por pulse falling edge, the vco supplies the limp-home clock frequency to the 13-stage counter, as the bcsp output is forced high and mcs is forced low. xclk, bclk and mclk are forced to be pclk, which is supplied by the vco at f vcomin . the initial period taken for the 13-stage counter to reach 4096 defines the internal reset period. if the clock monitor indicates the presence of an external clock during the internal reset period, limp-home mode is de-asserted and the 13-stage counter is then driven by extali clock. after the 13-stage counter reaches a count of 4096 xclk cycles, the internal reset is released, the 13-stage counter is reset and the mcu exits reset normally using extali clock. however, if the crystal start-up time is longer than the initial count of 4096 xclk cycles, or in the absence of an external clock, the mcu will leave the reset state in limp-home mode. the lhome flag is set and lhif limp-home interrupt request is set, to indicate it is not operating at the desired frequency. then after yet another 4096 xclk cycles followed regularly by 8192 xclk cycles (corresponding to the 13-stage counter timing out), a check of the clock monitor status is performed. when the presence of an external clock is detected limp-home mode is exited generating a limp-home interrupt if enabled. caution: the clock monitor circuit can be misled by the extali clock into reporting a good signal before it has fully stabilised. under these conditions improper extali clock cycles can occur on sysclk. this may lead to a code runaway. to ensure that this situation does not occur, the external reset period should be longer than the oscillator stabilisation time - this is an application dependent parameter. with the vddpll supply voltage at vss level, the pll module and hence limp-home mode are disabled, the device will remain effectively in a static state whilst there is no activity on extali. the internal reset period and mcu operation will execute only on extali clock. note: the external clock signal must stabilise within the initial 4096 reset counter cycles. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 166 clock functions motorola 11.6.3 stop exit and fast stop recovery stop mode is entered when a stop instruction is executed. recovery from stop depends primarily on the state of the three status bits nolhm, cme & dly. the dly bit controls the duration of the waiting period between the actual exit for some key blocks (e.g. clock monitor, clock generators) and the effective exit from stop for all the rest of the mcu. dly=1 enables the 13-stage counter to generate a 4096 count delay. dly=0 selects no delay. as the xclk is derived from the slow mode divider, the value in the slow register modifies the actual delay time. note: dly=0 is only recommended when there is a good signal available at the extal pin (e.g. an external square wave source). stop mode is exited with an external reset, an external interrupt from irq or xirq, a key wake-up interrupt from port j or port h, or an mscan wake-up interrupt. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 167 figure 11-5. stop exit and fast stop recovery 11.6.4 stop exit without limp home mode, clock monitor disabled (nolhm=1, cme=0, dly=x) if limp home mode is disabled (v ddpll =v ss or nolhm bit set) and the cme (or fcme) bit is cleared, the mcu goes into stop mode when a stop instruction is executed. if extali clock is present then exit from stop will occur normally using this clock. under this condition, dly should always be set to allow the crystal to stabilise and minimise the risk of code runaway. with dly=1 execution resumes after a delay of 4096 xclk cycles. note: the external clock signal should stabilise within the 4096 reset counter cycles. use of dly=0 is not recommended due to this requirement. clock monitor fail extali 13-stage counter 0 --> 4096 limp-home (clocked by xclk) bcsp restore bcsp sysclk pllclk (l.h.) restore pllclk or extali stop (dly = 1) stop (dly = 0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 168 clock functions motorola 11.6.5 executing the stop instruction without limp home mode, clock monitor enabled (nolhm=1, cme=1, dly=x) if the nolhm bit and the cme (or fcme) bits are set, a clock monitor failure is detected when a stop instruction is executed and the mcu resets via the clock monitor reset vector. 11.6.6 stop exit in limp home mode with delay (nolhm=0, cme=x, dly=1) if the nolhm bit is cleared, then the cme (or fcme) bit is masked when a stop instruction is executed to prevent a clock monitor failure. when coming out of stop mode, the mcu goes into limp-home mode where cme and fcme signals are asserted. when using a crystal oscillator, a normal stop exit sequence requires the dly bit to be set to allow for the crystal stabilization period. with the 13-stage counter clocked by the vco (at f vcomin ), following a delay of 4096 xclk cycles at the limp-home frequency, if the clock monitor indicates the presence of an external clock, the limp-home mode is de-asserted and the mcu exits stop normally using extali clock. where the crystal start-up time is longer than the initial count of 4096 xclk cycles, or in the absence of an external clock, the mcu recovers from stop following the 4096 count in limp-home mode with both the lhome flag set and the lhif limp-home interrupt request set to indicate it is not operating at the desired frequency. each time the 13-stage counter reaches a count of 4096 xclk cycles, a check of the clock monitor status is performed. when the presence of an external clock is detected, limp-home mode is exited and the lhome flag is cleared. this sets the limp-home interrupt flag and if enabled by the lhie bit, the limp-home mode interrupt is requested. caution: the clock monitor circuit can be misled by extali clock into reporting a good signal before it has fully stabilised. under these conditions, f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 169 improper extali clock cycles can occur on sysclk. this may lead to a code runaway. 11.6.7 stop exit in limp home mode without delay (fast stop recovery) (nolhm=0, cme=x, dly=0) fast stop recovery refers to any exit from stop using dly=0. if the nolhm bit is cleared, then the cme (or fcme) bit is masked when a stop instruction is executed to prevent a clock monitor failure. when coming out of stop mode, the mcu goes into limp-home mode where cme and fcme signals are asserted. when using a crystal oscillator, it is possible to exit stop with the dly bit cleared. in this case, stop is de-asserted without delay and the mcu will execute software in limp-home mode, giving the crystal oscillator time to stablise. caution: this mode is not recommended since the risk of the clock monitor detecting incorrect clocks is high. each time the 13-stage counter reaches a count of 4096 xclk cycles (every 8192 cycles), a check of the clock monitor status is performed. if the clock monitor indicates the presence of an external clock limp-home mode is de-asserted, the lhome flag is cleared and the limp-home interrupt flag is set. upon leaving limp-home mode, bcsp and mcs are restored to their values before the loss of clock, and all clocks return to their previous frequencies. if auto and bcsp were set before the clock loss, the sysclk ramps-up and the pll locks at the previously selected frequency. to prevent pll operation when the external clock frequency comes back, the software should clear the bcsp bit while running in limp-home mode. when using an external clock, i.e. a square wave source, it is possible to exit stop with the dly bit cleared. in this case the lhome flag is never set and stop is de-asserted without delay. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 170 clock functions motorola 11.6.8 pseudo-stop pseudo-stop is a low power mode similar to stop where the external oscillator is allowed to run (at reduced amplitude) whilst the rest of the part is in stop. this increases the current consumption over stop mode by the amount of current in the oscillator, but reduces wear and mechanical stress on the crystal. if the pstp bit in the pllcr register is set, the mcu goes into pseudo- stop mode when a stop instruction is executed. pseudo-stop mode is exited the same as stop with an external reset, an external interrupt from irq or xirq, a key wake-up interrupt from port j or port h, or an mscan wake-up interrupt. the effect of the dly bit is the same as noted above in stop exit and fast stop recovery . 11.6.9 pseudo-stop exit in limp home mode with delay (nolhm=0, cme=x, dly=1) when coming out of pseudo-stop mode with the nolhm bit cleared and the dly bit set, the mcu goes into limp-home mode (regardless of the state of the cme or fcme bits). the vco supplies the limp-home clock frequency to the 13-stage counter (xclk). the bcsp output is forced high and mcs is forced low. after the 13-stage counter reaches a count of 4096 xclk cycles, a check of the clock monitor is performed and as the crystal oscillator was kept running due to the pseudo-stop mode, the mcu exits stop normally, using the extali clock. in the case where a crystal failure occurred during pseudo-stop, then the mcu exits stop using the limp home clock (f vcomin ) with both the lhome flag set and the lhif limp- home interrupt request set to indicate it is not operating at the desired frequency. each time the 13-stage counter reaches a count of 4096 xclk cycles, a check of the clock monitor is performed. if the clock monitor indicates the presence of an external clock, limp-home mode is de-asserted, the lhome flag is cleared and the lhif limp-home f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 171 interrupt request is set to indicate a return to normal operation using extali clock. 11.6.10 pseudo-stop exit in limp home mode without delay (fast stop recovery) (nolhm=0, cme=x, dly=0) if pseudo-stop is exited with the nolhm bit set to 0 and the dly bit is cleared then the exit from pseudo-stop is accomplished without delay as in fast stop recovery. caution: where pseudo-stop recovers using the limp home clock the vco - which has been held in stop - must be restarted in order to supply the limp home frequency. this restart, which occurs at a high frequency and ramps toward the limp home frequency, is almost immediately supplied to the cpu before it may have reached the steady state frequency. it is possible that the initial clock frequency may be high enough to cause the cpu to function incorrectly with a resultant risk of code runaway. 11.6.11 pseudo-stop exit without limp home mode, clock monitor enabled (nolhm=1, cme=1, dly=x) if the nolhm bit is set and the cme (or fcme) bits are set, a clock monitor failure is detected when a stop instruction is executed and the mcu resets via the clock monitor reset vector. 11.6.12 pseudo-stop exit without limp home mode, clock monitor disabled (nolhm=1, cme=0, dly=1) if nolhm is set to 1 and the cme and fcme bits are cleared, the limp home clock is not used. in this mode, crystal activity is the only method by which the device may recover from pseudo-stop. the device will start execution with the extali clock following 4096 xclk cycles. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 172 clock functions motorola (nolhm=1, cme=0, dly=0) if nolhm is set to 1 and the cme and fcme bits are cleared, the limp home clock is not used. in this mode, crystal activity is the only method by which the device may recover from pseudo-stop. the device will start execution with the extali clock following 16 xclk cycles. caution: due to switching of the clock this configuration is not recommended. 11.6.13 summary of stop and pseudo-stop mode exit conditions table 11-1 and table 11-2 summarise the exit conditions from stop and pseudo-stop modes using interrupt, key-interrupt and xirq. a short reset pulse should not be used to exit stop or pseudo-stop mode because limp home mode is automatically entered after reset (when v ddpll =v dd ). the reset wakeup pulse must be longer than the oscillator startup time (as in power on reset) in order to remove the risk of code runaway. .. table 11-1. summary of stop mode exit conditions mode conditions summary stop exit without limp home mode, clock monitor disabled nolhm=1 cme=0 dly=x oscillator must be stable within 4096 xclk cycles. xclk can be modified by slow divider register. use of dly=0 only recommended with external clock. executing the stop instruction without limp home mode, clock monitor enabled nolhm=1 cme=1 dly=x when a stop instruction is executed the mcu resets via the clock monitor reset vector. stop exit in limp home mode with delay nolhm=0 cme=x dly=1 oscillator must be stable within 4096 f vcomin cycles or there is a possibility of code runaway as the clock monitor circuit can be misled by extali clock into reporting a good signal before it has fully stabilised stop exit in limp home mode without delay (fast stop recovery) nolhm=0 cme=x dly=0 this mode is only recommended for use with an external clock source. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 173 11.6.14 pll register descriptions read anytime, write anytime, except when bcsp = 1 (pll selected as bus clock). if the pll is on, the count in the loop divider (synr) register effectively multiplies up the bus frequency from the pll reference frequency by synr + 1. internally, sysclk runs at twice the bus frequency. caution should be used not to exceed the maximum rated operating frequency for the cpu. table 11-2. summary of pseudo stop mode exit conditions mode conditions summary pseudo-stop exit in limp home mode with delay nolhm=0 cme=x dly=1 cpu exits stop in limp home mode and oscillator running. if the oscillator fails during pseudo-stop and then recovers there is a possibility of code runaway as the clock monitor circuit can be misled by extali clock into reporting a good signal before it has fully stabilised pseudo-stop exit in limp home mode without delay (fast stop recovery) nolhm=0 cme=x dly=0 this mode is not recommended as it is possible that the initial vco clock frequency may be high enough to cause code runaway. pseudo-stop exit without limp home mode, clock monitor enabled nolhm=1 cme=1 dly=x when a stop instruction is executed the mcu resets via the clock monitor reset vector. pseudo-stop exit without limp home mode, clock monitor disabled, with delay nolhm=1 cme=0 dly=1 oscillator starts operation following 4096 xclk cycles (actual controlled by slow mode divider). pseudo-stop exit without limp home mode, clock monitor disabled, without delay nolhm=1 cme=0 dly=0 this mode is only recommended for use with an external clock source. bit 7654321bit 0 0 0 syn5 syn4 syn3 syn2 syn1 syn0 reset: 0 0 0 0 0 0 0 0 synr ? synthesizer register $0038 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 174 clock functions motorola read anytime, write anytime, except when bcsp = 1. the reference divider bits provides a finer granularity for the pll multiplier steps. the reference frequency is divided by refdv + 1. always reads zero, except in test modes. read anytime, refer to each bit for write conditions. lockif ? pll lock interrupt flag 0 = no change in lock bit. 1 = lock condition has changed, either from a locked state to an unlocked state or vice versa. to clear the flag, write one to this bit in pllflg. cleared in limp-home mode. bit 7654321bit 0 0 0 0 0 0 refdv2 refdv1 refdv0 reset: 0 0 000000 refdv ? reference divider register $0039 bit 7654321bit 0 tstout7 tstout6 tstout5 tstout4 tstout3 tstout2 tstout1 tstout0 reset: 0 0 000000 cgtflg ? clock generator test register $003a bit 7654321bit 0 lockif lock 0 0 0 0 lhif lhome reset: 0 0 0 0 0 0 0 0 pllflg ? pll flags $003b f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 175 lock ? locked phase lock loop circuit regardless of the bandwidth control mode (automatic or manual): 0 = pll vco is not within the desired tolerance of the target frequency. 1 = after the phase lock loop circuit is turned on, indicates the pll vco is within the desired tolerance of the target frequency. write has no effect on lock bit. this bit is cleared in limp-home mode as the lock detector cannot operate without the reference frequency. lhif ? limp-home interrupt flag 0 = no change in lhome bit. 1 = lhome condition has changed, either entered or exited limp- home mode. to clear the flag, write one to this bit in pllflg. lhome ? limp-home mode status 0 = mcu is operating normally, with extali clock available for generating clocks or as pll reference. 1 = loss of reference clock. cgm delivers pll vco limp-home frequency to the mcu. for limp-home mode, see limp-home and fast stop recovery modes . read and write anytime. exceptions are listed below for each bit. lockie ? pll lock interrupt enable 0 = pll lock interrupt is disabled 1 = pll lock interrupt is enabled forced to 0 when vddpll=0. bit 7654321bit 0 lockie pllon auto acq 0 pstp lhie nolhm reset: 0 ? (1) 10000 ? (2) pllcr ? pll control register $003c 1. set when vddpll power supply is high. forced to 0 when vddpll is low. 2. cleared when vddpll power supply is high. forced to 1 when vddpll is low. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 176 clock functions motorola pllon ? phase lock loop on 0 = turns the pll off. 1 = turns on the phase lock loop circuit. if auto is set, the pll will lock automatically. cannot be cleared when bcsp = 1 (pll selected as bus clock). forced to 0 when vddpll is at vss level. in limp-home mode, the output of pllon is forced to 1, but the pllon bit reads the latched value. auto ? automatic bandwidth control 0 = automatic mode control is disabled and the pll is under software control, using acq bit. 1 = automatic mode control is enabled. acq bit is read only. automatic bandwidth control selects either the high bandwidth (acquisition) mode or the low bandwidth (tracking) mode depending on how close to the desired frequency the vco is running. see electrical specifications . acq ? not in acquisition if auto = 1 (acq is read only) 0 = pll vco is not within the desired tolerance of the target frequency. the loop filter is in high bandwidth, acquisition mode. 1 = after the phase lock loop circuit is turned on, indicates the pll vco is within the desired tolerance of the target frequency. the loop filter is in low bandwidth, tracking mode. if auto = 0 0 = high bandwidth pll loop selected 1 = low bandwidth pll loop selected pstp ? pseudo-stop enable 0 = pseudo-stop oscillator mode is disabled 1 = pseudo-stop oscillator mode is enabled in pseudo-stop mode, the oscillator is still running while the mcu is maintained in stop mode. this allows for a faster stop recovery and reduces the mechanical stress and aging of the resonator in case frequent stop conditions at the expense of a slightly increased power consumption. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions limp-home and fast stop recovery modes mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 177 lhie ? limp-home interrupt enable 0 = limp-home interrupt is disabled 1 = limp-home interrupt is enabled forced to 0 when vddpll is at vss level. nolhm ? no limp-home mode 0 = loss of reference clock forces the mcu in limp-home mode. 1 = loss of reference clock causes standard clock monitor reset. read anytime; normal modes: write once; special modes: write anytime. forced to 1 when vddpll is at vss level. read and write anytime. exceptions are listed below for each bit. bcsp and bcss bits determine the clock used by the main system including the cpu and buses. bcsp ? bus clock select pll 0 = sysclk is derived from the crystal clock or from slwclk. 1 = sysclk source is the pll. cannot be set when pllon = 0. in limp-home mode, the output of bcsp is forced to 1, but the bcsp bit reads the latched value. bcss ? bus clock select slow 0 = sysclk is derived from the crystal clock extali. 1 = sysclk source is the slow clock slwclk. this bit has no effect when bcsp is set. mcs ? module clock select 0 = m clock is the same as pclk. 1 = m clock is derived from slow clock slwclk. this bit determines the clock used by the ect module and the baud rate generators of the scis. in limp-home mode, the output of mcs is forced to 0, but the mcs bit reads the latched value. bit 7654321bit 0 0 bcsp bcss 0 0 mcs 0 0 reset: 0 0 0 0 0 0 0 0 clksel ? clock generator clock select register $003d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 178 clock functions motorola read and write anytime. a write to this register changes the slwclk frequency with minimum delay (less than one slwclk cycle), thus allowing immediate tune- up of the performance versus power consumption for the modules using this clock. the frequency divide ratio is 2 times (slow), hence the divide range is 2 to 126 (not on first pass products). when slow = 0, the divider is bypassed. the generation of e, p and m clocks further divides slwclk by 2. hence, the final ratio of bus to extali frequency is programmable to 2, 4, 8, 12, 16, 20, ..., 252, by steps of 4. slwclk is a 50% duty cycle signal. bit 7654321bit 0 0 0 sldv5 sldv4 sldv3 sldv2 sldv1 sldv0 reset: 0 0 0 0 0 0 0 0 slow ? slow mode divider register $003e f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions system clock frequency formulas mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 179 11.7 system clock frequency formulas see figure 11-6 : slwclk = extali / ( 2 x slow ) slow = 1,2,..63 slwclk = extali slow = 0 pllclk = 2 x extali x (synr + 1) / (refdv + 1) eclk = sysclk / 2 xclk = slwclk / 2 pclk = sysclk / 2 bclk (1) = extali / 2 boolean equations: sysclk = (bcsp & pllclk) | (bcsp & bcss & extali) | (bcsp & bcss & slwclk) mclk = (pclk & mcs ) | (xclk & mcs) mscan system = (extali & clksrc) | (sysclk & clksrc) bdm system = (bclk & clksw) | (eclk & clksw) note: during limp-home mode pclk, eclk, bclk, mclk and xclk are supplied by vco (pllclk). 1. if sysclk is slower than extali (bcss=1, bcsp=0, slow>0), bclk becomes eclk. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 180 clock functions motorola 11.8 clock divider chains figure 11-6 , figure 11-7 , figure 11-8 , and figure 11-9 summarize the clock divider chains for the various peripherals on the 68hc(9)12dg128. figure 11-6. clock generation chain reduced consumption oscillator phase lock loop extal xtal 0:0 sysclk to buses, spi, pwm, atd0, atd1 to rti, cop bcsp bcss slow mode clock divider extali extali extali slwclk pllclk 0:1 bcsp bcss 1:x bcsp bcss mcs = 0 mcs = 1 2 2 to mscan clksrc = 1 tclks t clock generator e and p clock generator pclk eclk xclk to sci0, sci1, ect to cpu sync mclk to bdm 2 sync to cal to clock monitor clksrc = 0 clksw = 0 clksw = 1 bdmclk f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions clock divider chains mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 181 bus clock select bits bcsp and bcss in the clock select register (clksel) determine which clock drives sysclk for the main system including the cpu and buses. bcss has no effect if bcsp is set. during the transition, the clock select output will be held low and all cpu activity will cease until the transition is complete. the module clock select bit mcs determines the clock used by the ect module and the baud rate generators of the scis. in limp-home mode, the output of mcs is forced to 0, but the mcs bit reads the latched value. it allows normal operation of the serial and timer subsystems at a fixed reference frequency while allowing the cpu to operate at a higher, variable frequency. figure 11-7. clock chain for sci0, sci1, rti, cop xclk sc0bd modulus divider: 1, 2, 3, 4, 5, 6,...,8190, 8191 sci0 receive baud rate (16x) sci0 transmit baud rate (1x) bits: rtr2, rtr1, rtr0 to rti bits: cr2, cr1, cr0 to cop 16 sci1 receive baud rate (16x) sci1 transmit baud rate (1x) 16 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 4 4 4 2 4 2 4 register: copctl register: rtictl sc1bd modulus divider: 1, 2, 3, 4, 5, 6,...,8190, 8191 register: rtictl bit:rtbyp 2048 mclk f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 182 clock functions motorola figure 11-8. clock chain for ect bits: pr2, pr1, pr0 mclk pamod paclk pulse acc low byte paclk/256 pulse acc high byte paclk/65536 (paov) gate logic bits: paen, clk1, clk0 ten register: pactl register: tmsk2 paen 0:0:0 0:0:1 2 0:1:0 2 0:1:1 2 1:0:0 2 1:0:1 2 1:1:0 2 1:1:1 2 bits: mcpr1, mcpr0 mcen register: mcctl 0:0 0:1 4 1:0 2 1:1 2 0:x:x 1:0:0 1:0:1 1:1:0 1:1:1 to timer main counter (tcnt) modulus down counter port t7 prescaled mclk f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions clock divider chains mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 183 figure 11-9. clock chain for mscan, spi, atd0, atd1 and bdm pclk bits : spr2, spr1, spr0 spi bit rate 5-bit modulus counter (pr0-pr4) to atd0 and atd1 bkgd bdm bit clock: receive: detect falling edge, count 12 eclks, sample input transmit 1: detect falling edge, count 6 eclks while output is high impedance, drive out 1 e cycle pulse high, high imped- ance output again transmit 0: detect falling edge, drive out low, count 9 eclks, drive out 1 e cycle pulse high, high impedance output pin synchronizer logic bkgd in bkgd out bkgd direction 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 2 2 register: sp0br mscan clock clksrc extali sysclk clksw eclk bclk f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 184 clock functions motorola 11.9 computer operating properly (cop) the cop or watchdog timer is an added check that a program is running and sequencing properly. when the cop is being used, software is responsible for keeping a free running watchdog timer from timing out. if the watchdog timer times out it is an indication that the software is no longer being executed in the intended sequence; thus a system reset is initiated. three control bits allow selection of seven cop time-out periods. when cop is enabled, sometime during the selected period the program must write $55 and $aa (in this order) to the coprst register. if the program fails to do this the part will reset. if any value other than $55 or $aa is written, the part is reset. in addition, windowed cop operation can be selected. in this mode, writes to the coprst register must occur in the last 25% of the selected period. a premature write will also reset the part. 11.10 real-time interrupt there is a real time (periodic) interrupt available to the user. this interrupt will occur at one of seven selected rates. an interrupt flag and an interrupt enable bit are associated with this function. there are three bits for the rate select. 11.11 clock monitor the clock monitor circuit is based on an internal resistor-capacitor (rc) time delay. if no extali clock edges are detected within this rc time delay, the clock monitor can optionally generate a system reset. the clock monitor function is enabled/disabled by the cme control bit in the copctl register. this time-out is based on an rc delay so that the clock monitor can operate without any extali clock. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions clock function registers mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 185 clock monitor time-outs are shown in table 11-3 . the corresponding extali clock period with an ideal 50% duty cycle is twice this time-out value. 11.12 clock function registers all register addresses shown reflect the reset state. registers may be mapped to any 2k byte space. rtie ? real time interrupt enable read and write anytime. 0 = interrupt requests from rti are disabled. 1 = interrupt will be requested whenever rtif is set. rswai ? rti and cop stop while in wait write once in normal modes, anytime in special modes. read anytime. 0 = allows the rti and cop to continue running in wait. 1 = disables both the rti and cop whenever the part goes into wait. rsbck ? rti and cop stop while in background debug mode write once in normal modes, anytime in special modes. read anytime. 0 = allows the rti and cop to continue running while in background mode. 1 = disables both the rti and cop when the part is in background mode. this is useful for emulation. table 11-3. clock monitor time-outs supply range 5 v +/ ? 10% 2 ? 20 ?? ? ? real-time interrupt control register $0014 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 186 clock functions motorola rtbyp ? real time interrupt divider chain bypass write not allowed in normal modes, anytime in special modes. read anytime. 0 = divider chain functions normally. 1 = divider chain is bypassed, allows faster testing (the divider chain is normally xclk divided by 2 13 , when bypassed becomes xclk divided by 4). rtr2, rtr1, rtr0 ? real-time interrupt rate select read and write anytime. rate select for real-time interrupt. the clock used for this module is the xclk. rtif ? real time interrupt flag this bit is cleared automatically by a write to this register with this bit set. 0 = time-out has not yet occurred. 1 = set when the time-out period is met. table 11-4. real time interrupt rates rtr2 rtr1 rtr0 divide x by: time-out period x = 125 khz time-out period x = 500 khz time-out period x = 2.0 mhz time-out period x = 8.0 mhz 0 0 0 off off off off off 001 2 13 65.536 ms 16.384 ms 4.096 ms 1.024 ms 010 2 14 131.72 ms 32.768 ms 8.196 ms 2.048 ms 011 2 15 263.44 ms 65.536 ms 16.384 ms 4.096 ms 100 2 16 526.88 ms 131.72 ms 32.768 ms 8.196 ms 101 2 17 1.05 s 263.44 ms 65.536 ms 16.384 ms 110 2 18 2.11 s 526.88 ms 131.72 ms 32.768 ms 111 2 19 4.22 s 1.05 s 263.44 ms 65.536 ms bit 7654321bit 0 rtif0000000 reset: 0 0 0 0 0 0 0 0 rtiflg ? real time interrupt flag register $0015 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions clock function registers mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 187 cme ? clock monitor enable read and write anytime. if fcme is set, this bit has no meaning nor effect. 0 = clock monitor is disabled. slow clocks and stop instruction may be used. 1 = slow or stopped clocks (including the stop instruction) will cause a clock reset sequence or limp-home mode. see limp- home and fast stop recovery modes . on reset cme is 1 if vddpll is high cme is 0 if vddpll is low. note: the vddpll-dependent reset operation is not implemented on first pass products. in this case the state of cme on reset is 0. fcme ? force clock monitor enable write once in normal modes, anytime in special modes. read anytime. in normal modes, when this bit is set, the clock monitor function cannot be disabled until a reset occurs. 0 = clock monitor follows the state of the cme bit. 1 = slow or stopped clocks will cause a clock reset sequence or limp-home mode. see limp-home and fast stop recovery modes . bit 7654321bit 0 cme fcme fcmcop wcop disr cr2 cr1 cr0 reset: 0/1 0 000111normal reset: 0/1 0 001111special copctl ? cop control register $0016 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 188 clock functions motorola fcmcop ? force clock monitor reset or cop watchdog reset writes are not allowed in normal modes, anytime in special modes. read anytime. if disr is set, this bit has no effect. 0 = normal operation. 1 = a clock monitor failure reset or a cop failure reset is forced depending on the state of cme and if cop is enabled. wcop ? window cop mode write once in normal modes, anytime in special modes. read anytime. 0 = normal cop operation 1 = window cop operation when set, a write to the coprst register must occur in the last 25% of the selected period. a premature write will also reset the part. as long as all writes occur during this window, $55 can be written as often as desired. once $aa is written the time-out logic restarts and the user must wait until the next window before writing to coprst. please note, there is a fixed time uncertainty about the exact cop counter state when reset, as the initial prescale clock divider in the rti section is not cleared when the cop counter is cleared. this means the effective window is reduced by this uncertainty. table 11- 5 below shows the exact duration of this window for the seven available cop rates. cme cop enabled forced reset 0 0 none 0 1 cop failure 1 0 clock monitor failure 11 both (1) 1. highest priority interrupt vector is serviced. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions clock function registers mc68hc912dg128 ? rev 3.0 technical data motorola clock functions 189 disr ? disable resets from cop watchdog and clock monitor writes are not allowed in normal modes, anytime in special modes. read anytime. 0 = normal operation. 1 = regardless of other control bit states, cop and clock monitor will not generate a system reset. cr2, cr1, cr0 ? cop watchdog timer rate select bits these bits select the cop time-out rate. the clock used for this module is the xclk. write once in normal modes, anytime in special modes. read anytime. table 11-5. cop watchdog rates cr2 cr1 cr0 divide x clock by 8.0 mhz x clock. time-out window cop enabled: window start (1) window end effective window (2) 0 0 0 off off off off off 001 2 13 1.024 ms -0/+0.256 ms 0.768 ms 0.768 ms 0% (3) 010 2 15 4.096 ms -0/+0.256 ms 3.072 ms 3.840 ms 18.8 % 011 2 17 16.384 ms -0/+0.256 ms 12.288 ms 16.128 ms 23.4 % 100 2 19 65.536 ms -0/+1.024 ms 49.152 ms 64.512 ms 23.4 % 101 2 21 262.144 ms -0/+1.024 ms 196.608 ms 261.120 ms 24.6 % 110 2 22 524.288 ms -0/+1.024 ms 393.216 ms 523.264 ms 24.8 % 111 2 23 1.048576 ms -0/+1.024 ms 786.432 ms 1.047552 ms 24.9 % 1. time for writing $55 following previous cop restart of time-out logic due to writing $aa. 2. please refer to wcop bit description above. 3. window cop cannot be used at this rate. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
clock functions technical data mc68hc912dg128 ? rev 3.0 190 clock functions motorola always reads $00. writing $55 to this address is the first step of the cop watchdog sequence. writing $aa to this address is the second step of the cop watchdog sequence. other instructions may be executed between these writes but both must be completed in the correct order prior to time-out to avoid a watchdog reset. writing anything other than $55 or $aa causes a cop reset to occur. bit 7654321bit 0 bit 7654321bit 0 reset: 00000000 coprst ? arm/reset cop timer register $0017 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 191 technical data ? mc68hc912dg128 section 12. pulse width modulator 12.1 contents 12.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 12.3 pwm register description . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 12.4 pwm boundary cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 12.2 introduction the pulse-width modulator (pwm) subsystem provides four independent 8-bit pwm waveforms or two 16-bit pwm waveforms or a combination of one 16-bit and two 8-bit pwm waveforms. each waveform channel has a programmable period and a programmable duty-cycle as well as a dedicated counter. a flexible clock select scheme allows four different clock sources to be used with the counters. each of the modulators can create independent, continuous waveforms with software-selectable duty rates from 0 percent to 100 percent. the pwm outputs can be programmed as left-aligned outputs or center-aligned outputs. the period and duty registers are double buffered so that if they change while the channel is enabled, the change will not take effect until the counter rolls over or the channel is disabled. if the channel is not enabled, then writes to the period and/or duty register will go directly to the latches as well as the buffer, thus ensuring that the pwm output will always be either the old waveform or the new waveform, not some variation in between. a change in duty or period can be forced into immediate effect by writing the new value to the duty and/or period registers and then writing to the counter. this causes the counter to reset and the new duty and/or period values to be latched. in addition, since the counter is readable it is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 192 pulse width modulator motorola possible to know where the count is with respect to the duty value and software can be used to make adjustments by turning the enable bit off and on. the four pwm channel outputs share general-purpose port p pins. enabling pwm pins takes precedence over the general-purpose port. when pwm channels are not in use, the port pins may be used for discrete input/output. figure 12-1. block diagram of pwm left-aligned output channel gate pwcntx 8-bit compare = pwdtyx 8-bit compare = pwperx up /down from port p data register to pin driver ppolx clock source (eclk or scaled eclk) (clock edge sync) reset centr = 0 mux mux s r q q pwper pwdty pwenx ppol = 0 ppol = 1 sync f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator introduction mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 193 figure 12-2. block diagram of pwm center-aligned output channel gate pwcntx 8-bit compare = pwdtyx 8-bit compare = pwperx reset from port p data register to pin driver ppolx clock source (eclk or scaled eclk) (clock edge sync) up /down centr = 1 mux mux t q q pwdty pwenx ppol = 1 ppol = 0 (duty cycle) (period) pwper 2 (pwper ? pwdty) 2 pwdty sync f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 194 pulse width modulator motorola figure 12-3. pwm clock sources 8-bit down counter pclk2 mux pclk3 mux clock to pwm channel 2 clock to pwm channel 3 2 pwscnt1 8-bit scale register pwscal1 clock b clock s1** **clock s1 = (clock b)/2, (clock b)/4, (clock b)/6,... (clock b)/512 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 8-bit down counter pclk0 mux pclk1 mux clock to pwm channel 0 clock to pwm channel 1 2 pwscnt0 8-bit scale register pwscal0 clock a clock s0* *clock s0 = (clock a)/2, (clock a)/4, (clock a)/6,... (clock a)/512 register: bits: pckb2, pckb0 pckb1, = 0 = 0 bits: pcka2, pcka0 pcka1, pwpres psbck limbdm eclk psbck is bit 0 of pwctl register. internal signal limbdm is one if the mcu is in background debug mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 195 12.3 pwm register description read and write anytime. con23 ? concatenate pwm channels 2 and 3 when concatenated, channel 2 becomes the high-order byte and channel 3 becomes the low-order byte. channel 2 output pin is used as the output for this 16-bit pwm (bit 2 of port p). channel 3 clock- select control bits determines the clock source. channel 3 output pin becomes a general purpose i/o. 0 = channels 2 and 3 are separate 8-bit pwms. 1 = channels 2 and 3 are concatenated to create one 16-bit pwm channel. con01 ? concatenate pwm channels 0 and 1 when concatenated, channel 0 becomes the high-order byte and channel 1 becomes the low-order byte. channel 0 output pin is used as the output for this 16-bit pwm (bit 0 of port p). channel 1 clock- select control bits determine the clock source. channel 1 output pin becomes a general purpose i/o. 0 = channels 0 and 1 are separate 8-bit pwms. 1 = channels 0 and 1 are concatenated to create one 16-bit pwm channel. pcka2 ? pcka0 ? prescaler for clock a clock a is one of two clock sources which may be used for channels 0 and 1. these three bits determine the rate of clock a, as shown in table 12-1 . pwclk ? pwm clocks and concatenate $0040 bit 7 6 5 4 3 2 1 bit 0 con23 con01 pcka2 pcka1 pcka0 pckb2 pckb1 pckb0 reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 196 pulse width modulator motorola pckb2 ? pckb0 ? prescaler for clock b clock b is one of two clock sources which may be used for channels 2 and 3. these three bits determine the rate of clock b, as shown in table 12-1 . read and write anytime. pclk3 ? pwm channel 3 clock select 0 = clock b is the clock source for channel 3. 1 = clock s1 is the clock source for channel 3. pclk2 ? pwm channel 2 clock select 0 = clock b is the clock source for channel 2. 1 = clock s1 is the clock source for channel 2. pclk1 ? pwm channel 1 clock select 0 = clock a is the clock source for channel 1. 1 = clock s0 is the clock source for channel 1. table 12-1. clock a and clock b prescaler pcka2 (pckb2) pcka1 (pckb1) pcka0 (pckb0) value of clock a (b) 000 p 001 p ? ? ? ? ? ? ?? ? ? pwm clock select and polarity $0041 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 197 pclk0 ? pwm channel 0 clock select 0 = clock a is the clock source for channel 0. 1 = clock s0 is the clock source for channel 0. if a clock select is changed while a pwm signal is being generated, a truncated or stretched pulse may occur during the transition. the following four bits apply in left-aligned mode only: ppol3 ? pwm channel 3 polarity 0 = channel 3 output is low at the beginning of the period; high when the duty count is reached. 1 = channel 3 output is high at the beginning of the period; low when the duty count is reached. ppol2 ? pwm channel 2 polarity 0 = channel 2 output is low at the beginning of the period; high when the duty count is reached. 1 = channel 2 output is high at the beginning of the period; low when the duty count is reached. ppol1 ? pwm channel 1 polarity 0 = channel 1 output is low at the beginning of the period; high when the duty count is reached. 1 = channel 1 output is high at the beginning of the period; low when the duty count is reached. ppol0 ? pwm channel 0 polarity 0 = channel 0 output is low at the beginning of the period; high when the duty count is reached. 1 = channel 0 output is high at the beginning of the period; low when the duty count is reached. depending on the polarity bit, the duty registers may contain the count of either the high time or the low time. if the polarity bit is zero and left alignment is selected, the duty registers contain a count of the low time. if the polarity bit is one, the duty registers contain a count of the high time. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 198 pulse width modulator motorola setting any of the pwenx bits causes the associated port p line to become an output regardless of the state of the associated data direction register (ddrp) bit. this does not change the state of the data direction bit. when pwenx returns to zero, the data direction bit controls i/o direction. on the front end of the pwm channel, the scaler clock is enabled to the pwm circuit by the pwenx enable bit being high. when all four pwm channels are disabled, the prescaler counter shuts off to save power. there is an edge-synchronizing gate circuit to guarantee that the clock will only be enabled or disabled at an edge. read and write anytime. pwen3 ? pwm channel 3 enable the pulse modulated signal will be available at port p, bit 3 when its clock source begins its next cycle. 0 = channel 3 is disabled. 1 = channel 3 is enabled. pwen2 ? pwm channel 2 enable the pulse modulated signal will be available at port p, bit 2 when its clock source begins its next cycle. 0 = channel 2 is disabled. 1 = channel 2 is enabled. pwen1 ? pwm channel 1 enable the pulse modulated signal will be available at port p, bit 1 when its clock source begins its next cycle. 0 = channel 1 is disabled. 1 = channel 1 is enabled. bit 7654321bit 0 0000pwen3pwen2pwen1pwen0 reset: 00000000 pwen ? pwm enable $0042 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 199 pwen0 ? pwm channel 0 enable the pulse modulated signal will be available at port p, bit 0 when its clock source begins its next cycle. 0 = channel 0 is disabled. 1 = channel 0 is enabled. pwpres is a free-running 7-bit counter. read anytime. write only in special mode (smod = 1). read and write anytime. a write will cause the scaler counter pwscnt0 to load the pwscal0 value unless in special mode with discal = 1 in the pwtst register. pwm channels 0 and 1 can select clock s0 (scaled) as its input clock by setting the control bit pclk0 and pclk1 respectively. clock s0 is generated by dividing clock a by the value in the pwscal0 register + 1 and dividing again by two. when pwscal0 = $ff, clock a is divided by 256 then divided by two to generate clock s0. bit 7654321bit 0 0bit 654321bit 0 reset: 0 0 0 0 0 0 0 0 pwpres ? pwm prescale counter $0043 bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 0 0 0 0 0 0 pwscal0 ? pwm scale register 0 $0044 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 200 pulse width modulator motorola pwscnt0 is a down-counter that, upon reaching $00, loads the value of pwscal0. read any time. read and write anytime. a write will cause the scaler counter pwscnt1 to load the pwscal1 value unless in special mode with discal = 1 in the pwtst register. pwm channels 2 and 3 can select clock s1 (scaled) as its input clock by setting the control bit pclk2 and pclk3 respectively. clock s1 is generated by dividing clock b by the value in the pwscal1 register + 1 and dividing again by two. when pwscal1 = $ff, clock b is divided by 256 then divided by two to generate clock s1. pwscnt1 is a down-counter that, upon reaching $00, loads the value of pwscal1. read any time. bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 0 0 0 0 0 0 pwscnt0 ? pwm scale counter 0 value $0045 bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 000000 pwscal1 ? pwm scale register 1 $0046 bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 000000 pwscnt1 ? pwm scale counter 1 value $0047 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 201 read and write anytime. a write will cause the pwm counter to reset to $00. in special mode, if discr = 1, a write does not reset the pwm counter. the pwm counters are not reset when pwm channels are disabled. the counters must be reset prior to a new enable. each counter may be read any time without affecting the count or the operation of the corresponding pwm channel. writes to a counter cause the counter to be reset to $00 and force an immediate load of both duty and period registers with new values. to avoid a truncated pwm period, write to a counter while the counter is disabled. in left-aligned output mode, resetting the counter and starting the waveform output is controlled by a match between the period register and the value in the counter. in center-aligned output mode the counters operate as up/down counters, where a match in period changes the counter direction. the duty register changes the state of the output during the period to determine the duty. when a channel is enabled, the associated pwm counter starts at the count in the pwcntx register using the clock selected for that channel. in special mode, when discp = 1 and configured for left-aligned output, a match of period does not reset the associated pwm counter. bit 7654321bit 0 pwcnt0 bit 7654321bit 0 $0048 pwcnt1 bit 7654321bit 0 $0049 pwcnt2 bit 7654321bit 0 $004a pwcnt3 bit 7654321bit 0 $004b reset:00000000 pwcntx ? pwm channel counters f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 202 pulse width modulator motorola read and write anytime. the value in the period register determines the period of the associated pwm channel. if written while the channel is enabled, the new value will not take effect until the existing period terminates, forcing the counter to reset. the new period is then latched and is used until a new period value is written. reading this register returns the most recent value written. to start a new period immediately, write the new period value and then write the counter forcing a new period to start with the new period value. period = channel-clock-period ? + ? ?? ??? ? ?? ??? ?? ?? [ ?? [ ?? [ ?? [ ? ? pwm channel period registers bit 7654321bit 0 pwdty0 bit 7654321bit 0 $0050 pwdty1 bit 7654321bit 0 $0051 pwdty2 bit 7654321bit 0 $0052 pwdty3 bit 7654321bit 0 $0053 reset:11111111 pwdtyx ? pwm channel duty registers f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 203 the value in each duty register determines the duty of the associated pwm channel. when the duty value is equal to the counter value, the output changes state. if the register is written while the channel is enabled, the new value is held in a buffer until the counter rolls over or the channel is disabled. reading this register returns the most recent value written. if the duty register is greater than or equal to the value in the period register, there will be no duty change in state. if the duty register is set to $ff the output will always be in the state which would normally be the state opposite the ppolx value. left-aligned-output mode (centr = 0): duty cycle = [(pwdtyx + 1) / ???? ?] ?? ??? ? / ? ] ?? ???? ??? ? / ? ] ?? ???? / ?? ?] ?? ??? ? ? pwm halts while in wait mode 0 = allows pwm main clock generator to continue while in wait mode. 1 = halt pwm main clock generator when the part is in wait mode. centr ? center-aligned output mode to avoid irregularities in the pwm output mode, write the centr bit only when pwm channels are disabled. 0 = pwm channels operate in left-aligned output mode 1 = pwm channels operate in center-aligned output mode bit 7654321bit 0 0 0 0 pswai centr rdpp pupp psbck reset: 00000000 pwctl ? pwm control register $0054 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 204 pulse width modulator motorola rdpp ? reduced drive of port p 0 = all port p output pins have normal drive capability. 1 = all port p output pins have reduced drive capability. pupp ? pull-up port p enable 0 = all port p pins have an active pull-up device disabled. 1 = all port p pins have an active pull-up device enabled. psbck ? pwm stops while in background mode 0 = allows pwm to continue while in background mode. 1 = disable pwm input clock when the part is in background mode. read anytime but write only in special mode (smodn = 0). these bits are available only in special mode and are reset in normal mode. discr ? disable reset of channel counter on write to channel counter 0 = normal operation. write to pwm channel counter will reset channel counter. 1 = write to pwm channel counter does not reset channel counter. discp ? disable compare count period 0 = normal operation 1 = in left-aligned output mode, match of period does not reset the associated pwm counter register. discal ? disable load of scale-counters on write to the associated scale-registers 0 = normal operation 1 = write to pwscal0 and pwscal1 does not load scale counters bit 7654321bit 0 discr discp discal 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 pwtst ? pwm special mode register ( ? test ? ) $0055 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator pwm register description mc68hc912dg128 ? rev 3.0 technical data motorola pulse width modulator 205 portp can be read anytime. pwm functions share port p pins 3 to 0 and take precedence over the general-purpose port when enabled. when configured as input, a read will return the pin level. port p[7:4] will read as zero because there are no available external pins. when configured as output, a read will return the latched output data. port p[7:4] will read the last value written. a write will drive associated pins only if configured for output and the corresponding pwm channel is not enabled. after reset, all pins are general-purpose, high-impedance inputs. ddrp determines pin direction of port p when used for general-purpose i/o. read and write anytime. ddrp[7:4] ? data direction port p pin 7 ? 4 serve as memory locations since there are no corresponding port pins. ddrp[3:0] ? data direction port p pin 3 ? 0 0 = i/o pin configured as high impedance input 1 = i/o pin configured for output. bit 7654321bit 0 pp7 pp6 pp5 pp4 pp3 pp2 pp1 pp0 pwm ???? pwm3 pwm2 pwm1 pwm0 reset: ???????? portp ? port p data register $0056 bit 7654321bit 0 ddp7 ddp6 ddp5 ddp4 ddp3 ddp2 ddp1 ddp0 reset: 00000000 ddrp ? port p data direction register $0057 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
pulse width modulator technical data mc68hc912dg128 ? rev 3.0 206 pulse width modulator motorola 12.4 pwm boundary cases the boundary conditions for the pwm channel duty registers and the pwm channel period registers cause these results: table 12-2. pwm left-aligned boundary conditions pwdtyx pwperx ppolx output $ff > [ [ > [ ? 1high ? 0low ? $00 1 high ? $00 0 low table 12-3. pwm center-aligned boundary conditions pwdtyx pwperx ppolx output $00 > [ [ > [ ? 1high ? 0low ? $00 1 high ? $00 0 low f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 207 technical data ? mc68hc912dg128 section 13. enhanced capture timer 13.1 contents 13.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 13.3 enhanced capture timer modes of operation . . . . . . . . . . . . 214 13.4 timer registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 13.5 timer and modulus counter operation in different modes . .247 13.2 introduction the hc12 enhanced capture timer module has the features of the hc12 standard timer module enhanced by additional features in order to enlarge the field of applications, in particular for automotive abs applications. the additional features permit the operation of this timer module in a mode similar to the input control timer implemented on mc68hc11nb4. these additional features are:  16-bit buffer register for four input capture (ic) channels.  four 8-bit pulse accumulators with 8-bit buffer registers associated with the four buffered ic channels. configurable also as two 16-bit pulse accumulators.  16-bit modulus down-counter with 4-bit prescaler.  four user selectable delay counters for input noise immunity increase.  main timer prescaler extended to 7-bit. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 208 enhanced capture timer motorola this design specification describes the standard timer as well as the additional features. the basic timer consists of a 16-bit, software-programmable counter driven by a prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from microseconds to many seconds. a full access for the counter registers or the input capture/output compare registers should take place in one clock cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer introduction mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 209 figure 13-1. timer block diagram in latch mode 16 bit main timer pt1 comparator tc0h hold register pt0 pt3 pt2 pt4 pt5 pt6 pt7 edg0 edg1 edg2 edg3 mux prescaler m clock 16-bit load register 16-bit modulus 0 reset edg0 edg1 edg2 edg4 edg5 edg3 edg6 edg7 1, 2, ..., 128 1, 4, 8, 16 16-bit free-running latch underflow main timer prescaler tc0 capture/compare register comparator tc1 capture/compare register comparator tc2 capture/compare register comparator tc3 capture/compare register comparator tc4 capture/compare register comparator tc5 capture/compare register comparator tc6 capture/compare register comparator tc7 capture/compare register pin logic pin logic pin logic pin logic pin logic pin logic pin logic pin logic delay counter delay counter delay counter delay counter m clock tc1h hold register tc2h hold register tc3h hold register mux mux mux pa0h hold register pac0 0 reset pa1h hold register pac1 0 reset pa2h hold register pac2 0 reset pa3h hold register pac3 write $0000 to modulus counter iclat, latq, bufen (force latch) latq (mdc latch enable) down counter f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 210 enhanced capture timer motorola figure 13-2. timer block diagram in queue mode 16 bit main timer pt1 comparator tc0h hold register pt0 pt3 pt2 pt4 pt5 pt6 pt7 edg0 edg1 edg2 edg3 mux prescaler m clock 16-bit load register 16-bit modulus 0 reset edg0 edg1 edg2 edg4 edg5 edg3 edg6 edg7 1, 2, ..., 128 1, 4, 8, 16 16-bit free-running latch0 main timer prescaler tc0 capture/compare register comparator tc1 capture/compare register comparator tc2 capture/compare register comparator tc3 capture/compare register comparator tc4 capture/compare register comparator tc5 capture/compare register comparator tc6 capture/compare register comparator tc7 capture/compare register pin logic pin logic pin logic pin logic pin logic pin logic pin logic pin logic delay counter delay counter delay counter delay counter m clock tc1h hold register tc2h hold register tc3h hold register mux mux mux pa0h hold register pac0 0 reset pa1h hold register pac1 0 reset pa2h hold register pac2 0 reset pa3h hold register pac3 latch1 latch3 latch2 latq , bufen (queue mode) read tc3h hold register read tc2h hold register read tc1h hold register read tc0h hold register down counter f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer introduction mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 211 figure 13-3. 8-bit pulse accumulators block diagram host cpu data bus pt0 load holding register and reset pulse accumulator 0 0 edg3 edg2 edg1 edg0 edge detector delay counter interrupt interrupt pt1 edge detector delay counter pt2 edge detector delay counter pt3 edge detector delay counter 8-bit pac0 (pacn0) pa0h holding register 0 8-bit pac1 (pacn1) pa1h holding register 0 8-bit pac2 (pacn2) pa2h holding register 0 8-bit pac3 (pacn3) pa3h holding register f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 212 enhanced capture timer motorola figure 13-4. 16-bit pulse accumulators block diagram edge detector 8-bit pac2 intermodule bus 8-bit pac3 pt7 pt0 m clock divide by 64 clock select clk0 clk1 4:1 mux timclk paclk paclk / 256 paclk / 65536 prescaled mclk (timer clock) interrupt mux (pamod) edge detector paca delay counter (pacn3) (pacn2) 8-bit pac0 8-bit pac1 interrupt pacb (pacn1) (pacn0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer introduction mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 213 figure 13-5. block diagram for port7 with output compare / pulse accumulator a figure 13-6. c3f-c0f interrupt flag setting pulse accumulator a pad (om7=1 or ol7=1) or (oc7m7 = 1) oc7 ptn edge detector delay counter 16-bit main timer tcn input capture reg. tcnh i.c. holding reg. bufen ? latq ? tfmod set cnf interrupt f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 214 enhanced capture timer motorola 13.3 enhanced capture timer modes of operation the enhanced capture timer has 8 input capture, output compare (ic/oc) channels same as on the hc12 standard timer (timer channels tc0 to tc7). when channels are selected as input capture by selecting the iosx bit in tios register, they are called input capture (ic) channels. four ic channels are the same as on the standard timer with one capture register which memorizes the timer value captured by an action on the associated input pin. four other ic channels, in addition to the capture register, have also one buffer called holding register. this permits to memorize two different timer values without generation of any interrupt. four 8-bit pulse accumulators are associated with the four buffered ic channels. each pulse accumulator has a holding register to memorize their value by an action on its external input. each pair of pulse accumulators can be used as a 16-bit pulse accumulator. the 16-bit modulus down-counter can control the transfer of the ic registers contents and the pulse accumulators to the respective holding registers for a given period, every time the count reaches zero. the modulus down-counter can also be used as a stand-alone time base with periodic interrupt capability. 13.3.1 ic channels the ic channels are composed of four standard ic registers and four buffered ic channels. an ic register is empty when it has been read or latched into the holding register. a holding register is empty when it has been read. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer enhanced capture timer modes of operation mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 215 13.3.1.1 non-buffered ic channels the main timer value is memorized in the ic register by a valid input pin transition. if the corresponding novwx bit of the icovw register is cleared, with a new occurrence of a capture, the contents of ic register are overwritten by the new value. if the corresponding novwx bit of the icovw register is set, the capture register cannot be written unless it is empty. this will prevent the captured value to be overwritten until it is read. 13.3.1.2 buffered ic channels there are two modes of operations for the buffered ic channels.  ic latch mode: when enabled (latq=1), the main timer value is memorized in the ic register by a valid input pin transition. the value of the buffered ic register is latched to its holding register by the modulus counter for a given period when the count reaches zero, by a write $0000 to the modulus counter or by a write to iclat in the mcctl register. if the corresponding novwx bit of the icovw register is cleared, with a new occurrence of a capture, the contents of ic register are overwritten by the new value. in case of latching, the contents of its holding register are overwritten. if the corresponding novwx bit of the icovw register is set, the capture register or its holding register cannot be written by an event unless they are empty (see ic channels ). this will prevent the captured value to be overwritten until it is read or latched in the holding register.  ic queue mode: when enabled (latq=0), the main timer value is memorized in the ic register by a valid input pin transition. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 216 enhanced capture timer motorola if the corresponding novwx bit of the icovw register is cleared, with a new occurrence of a capture, the value of the ic register will be transferred to its holding register and the ic register memorizes the new timer value. if the corresponding novwx bit of the icovw register is set, the capture register or its holding register cannot be written by an event unless they are empty (see ic channels ). in queue mode, reads of holding register will latch the corresponding pulse accumulator value to its holding register. 13.3.2 pulse accumulators there are four 8-bit pulse accumulators with four 8-bit holding registers associated with the four ic buffered channels. a pulse accumulator counts the number of active edges at the input of its channel. the user can prevent 8-bit pulse accumulators counting further than $ff by pacmx control bit in icsys ($ab). in this case a value of $ff means that 255 counts or more have occurred. each pair of pulse accumulators can be used as a 16-bit pulse accumulator. there are two modes of operation for the pulse accumulators. 13.3.2.1 pulse accumulator latch mode the value of the pulse accumulator is transferred to its holding register when the modulus down-counter reaches zero, a write $0000 to the modulus counter or when the force latch control bit iclat is written. at the same time the pulse accumulator is cleared. 13.3.2.2 pulse accumulator queue mode when queue mode is enabled, reads of an input capture holding register will transfer the contents of the associated pulse accumulator to its holding register. at the same time the pulse accumulator is cleared. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 217 13.3.3 modulus down-counter the modulus down-counter can be used as a time base to generate a periodic interrupt. it can also be used to latch the values of the ic registers and the pulse accumulators to their holding registers. the action of latching can be programmed to be periodic or only once. 13.4 timer registers input/output pins default to general-purpose i/o lines until an internal function which uses that pin is specifically enabled. the timer overrides the state of the ddr to force the i/o state of each associated port line when an output compare using a port line is enabled. in these cases the data direction bits will have no affect on these lines. when a pin is assigned to output an on-chip peripheral function, writing to this portt bit does not affect the pin but the data is stored in an internal latch such that if the pin becomes available for general-purpose output the driven level will be the last value written to the portt bit. read or write anytime. ios[7:0] ? input capture or output compare channel configuration 0 = the corresponding channel acts as an input capture 1 = the corresponding channel acts as an output compare. bit 7654321bit 0 ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 reset: 0 0 000000 tios ? timer input capture/output compare select $0080 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 218 enhanced capture timer motorola read anytime but will always return $00 (1 state is transient). write anytime. foc[7:0] ? force output compare action for channel 7-0 a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ? n ? to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcn register except the interrupt flag does not get set. read or write anytime. the bits of oc7m correspond bit-for-bit with the bits of timer port (portt). setting the oc7mn will set the corresponding port to be an output port regardless of the state of the ddrtn bit when the corresponding iosn bit is set to be an output compare. this does not change the state of the ddrt bits. at successful oc7, for each bit that is set in oc7m, the corresponding data bit oc7d is stored to the corresponding bit of the timer port. note: oc7m has priority over output action on the timer port enabled by omn and oln bits in tctl1 and tctl2. if an oc7m bit is set, it prevents the action of corresponding om and ol bits on the selected timer port. bit 7654321bit 0 foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 reset: 0 0 000000 cforc ? timer compare force register $0081 bit 7654321bit 0 oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 reset: 0 0 000000 oc7m ? output compare 7 mask register $0082 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 219 read or write anytime. the bits of oc7d correspond bit-for-bit with the bits of timer port (portt). when a successful oc7 compare occurs, for each bit that is set in oc7m, the corresponding data bit in oc7d is stored to the corresponding bit of the timer port. when the oc7mn bit is set, a successful oc7 action will override a successful oc[6:0] compare action during the same cycle; therefore, the ocn action taken will depend on the corresponding oc7d bit. the 16-bit main timer is an up counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read anytime. write has no meaning or effect in the normal mode; only writable in special modes (smodn = 0). bit 7654321bit 0 oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 reset: 0 0 000000 oc7d ? output compare 7 data register $0083 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 reset: 0 0 000000 tcnt ? timer count register $0084 ? $0085 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 220 enhanced capture timer motorola the period of the first count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. read or write anytime. ten ? timer enable 0 = disables the main timer, including the counter. can be used for reducing power consumption. 1 = allows the timer to function normally. if for any reason the timer is not active, there is no ???? ???? ?????? ? ? timer module stops while in wait 0 = allows the timer module to continue running during wait. 1 = disables the timer module when the mcu is in the wait mode. timer interrupts cannot be used to get the mcu out of wait. tswai also affects pulse accumulators and modulus down counters. tsbck ? timer and modulus counter stop while in background mode 0 = allows the timer and modulus counter to continue running while in background mode. 1 = disables the timer and modulus counter whenever the mcu is in background mode. this is useful for emulation. tbsck does not stop the pulse accumulator. tffca ? timer fast flag clear all 0 = allows the timer flag clearing to function normally. 1 = for tflg1($8e), a read from an input capture or a write to the output compare channel ($90 ? $9f) causes the corresponding channel flag, cnf, to be cleared. for tflg2 ($8f), any access bit 7654321bit 0 ten tswai tsbck tffca reset: 0 0 0 0 0 0 0 0 tscr ? timer system control register $0086 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 221 to the tcnt register ($84, $85) clears the tof flag. any access to the pacn3 and pacn2 registers ($a2, $a3) clears the paovf and paif flags in the paflg register ($a1). any access to the pacn1 and pacn0 registers ($a4, $a5) clears the pbovf flag in the pbflg register ($b1). any access to the mccnt register ($b6, $b7) clears the mczf flag in the mcflg register ($a7). this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to avoid accidental flag clearing due to unintended accesses. bit 7654321bit 0 reset: 00000000 tqcr ? reserved $0087 bit 76 5 4 3 2 1bit 0 om7ol7om6ol6om5ol5om4ol4 reset: 0 0 0 0 0 0 0 0 tctl1 ? timer control register 1 $0088 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 222 enhanced capture timer motorola read or write anytime. omn ? output mode oln ? output level these eight pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocn compare. when either omn or oln is one, the pin associated with ocn becomes an output tied to ocn regardless of the state of the associated ddrt bit. note: to enable output action by omn and oln bits on the timer port, the corresponding bit in oc7m should be cleared. to operate the 16-bit pulse accumulators a and b (paca and pacb) independently of input capture or output compare 7 and 0 respectively the user must set the corresponding bits iosn = 1, omn = 0 and oln = 0. oc7m7 or oc7m0 in the oc7m register must also be cleared. bit 7654321bit 0 om3 ol3 om2 ol2 om1 ol1 om0 ol0 reset: 00000000 tctl2 ? timer control register 2 $0089 table 13-1. compare result output action omn oln action 0 0 timer disconnected from output pin logic 0 1 toggle ocn output line 1 0 clear ocn output line to zero 1 1 set ocn output line to one f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 223 read or write anytime. edgnb, edgna ? input capture edge control these eight pairs of control bits configure the input capture edge detector circuits. read or write anytime. bit 7654321bit 0 edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a reset: 0 0 000000 tctl3 ? timer control register 3 $008a bit 76 5 4 3 2 1bit 0 edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a reset: 0 0 0 0 0 0 0 0 tctl4 ? timer control register 4 $008b table 13-2edge detector circuit configuration edgnb edgna configuration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling) bit 7654321bit 0 c7i c6i c5i c4i c3i c2i c1i c0i reset: 0 0 000000 tmsk1 ? timer interrupt mask 1 $008c f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 224 enhanced capture timer motorola the bits in tmsk1 correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding flag is disabled from causing a hardware interrupt. if set, the corresponding flag is enabled to cause a hardware interrupt. read or write anytime. c7i ? c0i ? input capture/output compare ? x ? interrupt enable. read or write anytime. toi ? timer overflow interrupt enable 0 = interrupt inhibited 1 = hardware interrupt requested when tof flag set pupt ? timer port pull-up resistor enable this enable bit controls pull-up resistors on the timer port pins when the pins are configured as inputs. 0 = disable pull-up resistor function 1 = enable pull-up resistor function rdpt ? timer port drive reduction this bit reduces the effective output driver size which can reduce power supply current and generated noise depending upon pin loading. 0 = normal output drive capability 1 = enable output drive reduction function tcre ? timer counter reset enable this bit allows the timer counter to be reset by a successful output compare 7 event. this mode of operation is similar to an up-counting modulus counter. bit 7654321bit 0 toi 0 pupt rdpt tcre pr2 pr1 pr0 reset:00000000 tmsk2 ? timer interrupt mask 2 $008d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 225 0 = counter reset inhibited and counter free runs 1 = counter reset by a successful output compare 7 if tc7 = $0000 and tcre = 1, tcnt will stay at $0000 continuously. if tc7 = $ffff and tcre = 1, tof will never be set when tcnt is reset from $ffff to $0000. pr2, pr1, pr0 ? timer prescaler select these three bits specify the number of ?????? ?????????? ???????????? ???????? ??? ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 226 enhanced capture timer motorola tflg1 indicates when interrupt conditions have occurred. to clear a bit in the flag register, write a one to the bit. use of the tfmod bit in the icsys register ($ab) in conjunction with the use of the icovw register ($aa) allows a timer interrupt to be generated after capturing two values in the capture and holding registers instead of generating an interrupt for every capture. read anytime. write used in the clearing mechanism (set bits cause corresponding bits to be cleared). writing a zero will not affect current status of the bit. when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel ($90 ? $9f) will cause the corresponding channel flag cnf to be cleared. c7f ? c0f ? input capture/output compare channel ? n ? flag. tflg2 indicates when interrupt conditions have occurred. to clear a bit in the flag register, set the bit to one. read anytime. write used in clearing mechanism (set bits cause corresponding bits to be cleared). bit 7654321bit 0 c7f c6f c5f c4f c3f c2f c1f c0f reset: 0 0 0 0 0 0 0 0 tflg1 ? main timer interrupt flag 1 $008e bit 7654321bit 0 tof0000000 reset: 0 0 0 0 0 0 0 0 tflg2 ? main timer interrupt flag 2 $008f f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 227 any access to tcnt will clear tflg2 register if the tffca bit in tscr register is set. tof ? timer overflow flag set when 16-bit free-running timer overflows from $ffff to $0000. this bit is cleared automatically by a write to the tflg2 register with bit 7 set. (see also tcre control bit explanation.) bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc0 ? timer input capture/output compare register 0 $0090 ? $0091 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc1 ? timer input capture/output compare register 1 $0092 ? $0093 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc2 ? timer input capture/output compare register 2 $0094 ? $0095 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc3 ? timer input capture/output compare register 3 $0096 ? $0097 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 228 enhanced capture timer motorola depending on the tios bit for the corresponding channel, these registers are used to latch the value of the free-running counter when a defined transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc4 ? timer input capture/output compare register 4 $0098 ? $0099 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc5 ? timer input capture/output compare register 5 $009a ? $009b bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc6 ? timer input capture/output compare register 6 $009c ? $009d bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc7 ? timer input capture/output compare register 7 $009e ? $009f f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 229 read anytime. write anytime for output compare function. writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to $0000. 16-bit pulse accumulator a (paca) is formed by cascading the 8-bit pulse accumulators pac3 and pac2. when paen is set, the paca is enabled. the paca shares the input pin with ic7. read: any time write: any time paen ? pulse accumulator a system enable 0 = 16-bit pulse accumulator a system disabled. 8-bit pac3 and pac2 can be enabled when their related enable bits in icpacr ($a8) are set. pulse accumulator input edge flag (paif) function is disabled. 1 = pulse accumulator a system enabled. the two 8-bit pulse accumulators pac3 and pac2 are cascaded to form the paca 16-bit pulse accumulator. when paca in enabled, the pacn3 and pacn2 registers contents are respectively the high and low byte of the paca. pa3en and pa2en control bits in icpacr ($a8) have no effect. pulse accumulator input edge flag (paif) function is enabled. paen is independent from ten. with timer disabled, the pulse accumulator can still function unless pulse accumulator is disabled. bit 7654321bit 0 0 paen pamod pedge clk1 clk0 paovi pai reset: 00000000 pactl ? 16-bit pulse accumulator a control register $00a0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 230 enhanced capture timer motorola pamod ? pulse accumulator mode 0 = event counter mode 1 = gated time accumulation mode pedge ? pulse accumulator edge control for pamod bit = 0 (event counter mode). 0 = falling edges on pt7 pin cause the count to be incremented 1 = rising edges on pt7 pin cause the count to be incremented for pamod bit = 1 (gated time accumulation mode). 0 = pt7 input pin high enables m divided by 64 clock to pulse accumulator and the trailing falling edge on pt7 sets the paif flag. 1 = pt7 input pin low enables m divided by 64 clock to pulse accumulator and the trailing rising edge on pt7 sets the paif flag. if the timer is not active (ten = 0 in tscr), there is no divide-by-64 since the e ??????? ?? ? clock select bits if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens immediately after these bits are written. pamod pedge pin action 0 0 falling edge 0 1 rising edge 1 0 div. by 64 clock enabled with pin high level 1 1 div. by 64 clock enabled with pin low level clk1 clk0 clock source 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 11 use paclk/65536 as timer counter clock frequency f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 231 paovi ? pulse accumulator a overflow interrupt enable 0 = interrupt inhibited 1 = interrupt requested if paovf is set pai ? pulse accumulator input interrupt enable 0 = interrupt inhibited 1 = interrupt requested if paif is set read or write anytime. when the tffca bit in the tscr register is set, any access to the pacnt register will clear all the flags in the paflg register. paovf ? pulse accumulator a overflow flag set when the 16-bit pulse accumulator a overflows from $ffff to $0000,or when 8-bit pulse accumulator 3 (pac3) overflows from $ff to $00. this bit is cleared automatically by a write to the paflg register with bit 1 set. paif ? pulse accumulator input edge flag set when the selected edge is detected at the pt7 input pin. in event mode the event edge triggers paif and in gated time accumulation mode the trailing edge of the gate signal at the pt7 input pin triggers paif. this bit is cleared by a write to the paflg register with bit 0 set. any access to the pacn3, pacn2 registers will clear all the flags in this register when tffca bit in register tscr($86) is set. bit 7654321bit 0 0 0 0 0 0 0 paovf paif reset: 0 0 0 0 0 0 0 0 paflg ? pulse accumulator a flag register $00a1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 232 enhanced capture timer motorola read: any time write: any time the two 8-bit pulse accumulators pac3 and pac2 are cascaded to form the paca 16-bit pulse accumulator. when paca in enabled (paen=1 in pactl, $a0) the pacn3 and pacn2 registers contents are respectively the high and low byte of the paca. when pacn3 overflows from $ff to $00, the interrupt flag paovf in paflg ($a1) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: any time write: any time the two 8-bit pulse accumulators pac1 and pac0 are cascaded to form the pacb 16-bit pulse accumulator. when pacb in enabled, (pben=1 bit 7654321bit 0 $00a2bit 7654321bit 0pacn3 (hi) $00a3bit 7654321bit 0pacn2 (lo) reset: 00000000 pacn3, pacn2 ? pulse accumulators count registers $00a2, $00a3 bit 7654321bit 0 $00a4bit 7654321bit 0pacn1 (hi) $00a5bit 7654321bit 0pacn0 (lo) reset: 0 0 0 0 0 0 0 0 pacn1, pacn0 ? pulse accumulators count registers $00a4, $00a5 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 233 in pbctl, $b0) the pacn1 and pacn0 registers contents are respectively the high and low byte of the pacb. when pacn1 overflows from $ff to $00, the interrupt flag pbovf in pbflg ($b1) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: any time write: any time mczi ? modulus counter underflow interrupt enable 0 = modulus counter interrupt is disabled. 1 = modulus counter interrupt is enabled. modmc ? modulus mode enable 0 = the counter counts once from the value written to it and will stop at $0000. 1 = modulus mode is enabled. when the counter reaches $0000, the counter is loaded with the latest value written to the modulus count register. note: for proper operation, the mcen bit should be cleared before modifying the modmc bit in order to reset the modulus counter to $ff. rdmcl ? read modulus down-counter load 0 = reads of the modulus count register will return the present value of the count register. 1 = reads of the modulus count register will return the contents of the load register. bit 7654321bit 0 mczi modmc rdmcl iclat flmc mcen mcpr1 mcpr0 reset: 0 0 0 0 0 0 0 0 mcctl ? 16-bit modulus down-counter control register $00a6 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 234 enhanced capture timer motorola iclat ? input capture force latch action when input capture latch mode is enabled (latq and bufen bit in icsys ($ab) are set), a write one to this bit immediately forces the contents of the input capture registers tc0 to tc3 and their corresponding 8-bit pulse accumulators to be latched into the associated holding registers. the pulse accumulators will be automatically cleared when the latch action occurs. writing zero to this bit has no effect. read of this bit will return always zero. flmc ? force load register into the modulus counter count register this bit is active only when the modulus down-counter is enabled (mcen=1). a write one into this bit loads the load register into the modulus counter count register. this also resets the modulus counter prescaler. write zero to this bit has no effect. when modmc=0, counter starts counting and stops at $0000. read of this bit will return always zero. mcen ? modulus down-counter enable 0 = modulus counter disabled. 1 = modulus counter is enabled. when mcen=0, the counter is preset to $ffff. this will prevent an early interrupt flag when the modulus down-counter is enabled. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 235 mcpr1, mcpr0 ? modulus counter prescaler select these two bits specify the division rate of the modulus counter prescaler. the newly selected prescaler division rate will not be effective until a load of the load register into the modulus counter count register occurs. read: any time write: only for clearing bit 7 mczf ? modulus counter underflow interrupt flag the flag is set when the modulus down-counter reaches $0000. writing a1 to this bit clears the flag (if tffca=0). writing a zero has no effect. any access to the mccnt register will clear the mczf flag in this register when tffca bit in register tscr($86) is set. mcpr1 mcpr0 prescaler division rate 00 1 01 4 10 8 11 16 bit 7654321bit 0 mczf 0 0 0 polf3 polf2 polf1 polf0 reset: 0 0 000000 mcflg ? 16-bit modulus down-counter flag register $00a7 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 236 enhanced capture timer motorola polf3 ? polf0 ? first input capture polarity status these are read only bits. write to these bits has no effect. each status bit gives the polarity of the first edge which has caused an input capture to occur after capture latch has been read. each polfx corresponds to a timer portx input. 0 = the first input capture has been caused by a falling edge. 1 = the first input capture has been caused by a rising edge. the 8-bit pulse accumulators pac3 and pac2 can be enabled only if paen in patcl ($a0) is cleared. if paen is set, pa3en and pa2en have no effect. the 8-bit pulse accumulators pac1 and pac0 can be enabled only if pben in pbtcl ($b0) is cleared. if pben is set, pa1en and pa0en have no effect. read: any time write: any time paxen ? 8-bit pulse accumulator ? x ? enable 0 = 8-bit pulse accumulator is disabled. 1 = 8-bit pulse accumulator is enabled. bit 7654321bit 0 0 0 0 0 pa3en pa2en pa1en pa0en reset: 0 0 0 0 0 0 0 0 icpacr ? input control pulse accumulators control register $00a8 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 237 read: any time write: any time if enabled, after detection of a valid edge on input capture pin, the delay counter counts the pre-selected number of m clock (module clock) cycles, then it will generate a pulse on its output. the pulse is generated only if the level of input signal, after the preset delay, is the opposite of the level before the transition.this will avoid reaction to narrow input pulses. after counting, the counter will be cleared automatically. delay between two active edges of the input signal period should be longer than the selected counter delay. dlyx ? delay counter select bit 7654321bit 0 000000dly1dly0 reset: 0 0 000000 dlyct ? delay counter control register $00a9 dly1 dly0 delay 0 0 disabled (bypassed) 0 1 256 m clock cycles 1 0 512 m clock cycles 1 1 1024 m clock cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 238 enhanced capture timer motorola read: any time write: any time an ic register is empty when it has been read or latched into the holding register. a holding register is empty when it has been read. novwx ? no input capture overwrite 0 = the contents of the related capture register or holding register can be overwritten when a new input capture or latch occurs. 1 = the related capture register or holding register cannot be written by an event unless they are empty (see ic channels ). this will prevent the captured value to be overwritten until it is read or latched in the holding register. bit 7654321bit 0 novw7 novw6 novw5 novw4 novw3 novw2 novw1 novw0 reset: 0 0 000000 icovw ? input control overwrite register $00aa f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 239 read: any time write: may be written once (smodn=1). writes are always permitted when smodn=0. shxy ? share input action of input capture channels x and y 0 = normal operation 1 = the channel input ? x ? causes the same action on the channel ? y ? . the port pin ? x ? and the corresponding edge detector is used to be active on the channel ? y ? . tfmod ? timer flag-setting mode use of the tfmod bit in the icsys register ($ab) in conjunction with the use of the icovw register ($aa) allows a timer interrupt to be generated after capturing two values in the capture and holding registers instead of generating an interrupt for every capture. by setting tfmod in queue mode, when novw bit is set and the corresponding capture and holding registers are emptied, an input capture event will first update the related input capture register with the main timer contents. at the next event the tcn data is transferred to the tcnh register, the tcn is updated and the cnf interrupt flag is set. see figure 13-6 . in all other input capture cases the interrupt flag is set by a valid external event on ptn. 0 = the timer flags c3f ? c0f in tflg1 ($8e) are set when a valid input capture transition on the corresponding port pin occurs. 1 = if in queue mode (bufen=1 and latq=0), the timer flags c3f ? c0f in tflg1 ($8e) are set only when a latch on the corresponding holding register occurs. if the queue mode is not engaged, the timer flags c3f ? c0f are set the same way as for tfmod=0. bit 7654321bit 0 sh37 sh26 sh15 sh04 tfmod pacmx bufen latq reset: 0 0 000000 icsys ? input control system control register $00ab f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 240 enhanced capture timer motorola pacmx ? 8-bit pulse accumulators maximum count 0 = normal operation. when the 8-bit pulse accumulator has reached the value $ff, with the next active edge, it will be incremented to $00. 1 = when the 8-bit pulse accumulator has reached the value $ff, it will not be incremented further. the value $ff indicates a count of 255 or more. bufen ? ic buffer enable 0 = input capture and pulse accumulator holding registers are disabled. 1 = input capture and pulse accumulator holding registers are enabled. the latching mode is defined by latq control bit. write one into iclat bit in mcctl ($a6), when latq is set will produce latching of input capture and pulse accumulators registers into their holding registers. latq ? input control latch or queue mode enable the bufen control bit should be set in order to enable the ic and pulse accumulators holding registers. otherwise latq latching modes are disabled. write one into iclat bit in mcctl ($a6), when latq and bufen are set will produce latching of input capture and pulse accumulators registers into their holding registers. 0 = queue mode of input capture is enabled. the main timer value is memorized in the ic register by a valid input pin transition. with a new occurrence of a capture, the value of the ic register will be transferred to its holding register and the ic register memorizes the new timer value. 1 = latch mode is enabled. latching function occurs when modulus down-counter reaches zero or a zero is written into the count register mccnt (see buffered ic channels ). with a latching event the contents of ic registers and 8-bit pulse accumulators are transferred to their holding registers. 8-bit pulse accumulators are cleared. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 241 read: any time write: only in special mode (smod = 1). tcbyp ? main timer divider chain bypass 0 = normal operation 1 = for testing only. the 16-bit free-running timer counter is divided into two 8-bit halves and the prescaler is bypassed. the clock drives both halves directly. when the high byte of timer counter tcnt ($84) overflows from $ff to $00, the tof flag in tflg2 ($8f) will be set. read: any time (inputs return pin level; outputs return data register contents) write: data stored in an internal latch (drives pins only if configured for output) since the output compare 7 shares the pin with pulse accumulator input, the only way for pulse accumulator to receive an independent input from output compare 7 is setting both om7 & ol7 to be zero, and also oc7m7 in oc7m register to be zero. bit 7654321bit 0 000000tcbyp0 reset: 0 0 000000 timtst ? timer test register $00ad bit 7654321bit 0 port pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 timer i/oc7 i/oc6 i/oc5 i/oc4 i/oc3 i/oc2 i/oc1 i/oc0 reset: 0 0 000000 portt ? timer port data register $00ae f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 242 enhanced capture timer motorola oc7 is still able to reset the counter if enabled while pt7 is used as input to pulse accumulator. portt can be read anytime. when configured as an input, a read will return the pin level. when configured as an output, a read will return the latched output data. note: writes do not change pin state when the pin is configured for timer output. the minimum pulse width for pulse accumulator input should always be greater than the width of two module clocks due to input synchronizer circuitry. the minimum pulse width for the input capture should always be greater than the width of two module clocks due to input synchronizer circuitry. read or write any time. 0 = configures the corresponding i/o pin for input only 1 = configures the corresponding i/o pin for output. the timer forces the i/o state to be an output for each timer port line associated with an enabled output compare. in these cases the data direction bits will not be changed, but have no effect on the direction of these pins. the ddrt will revert to controlling the i/o direction of a pin when the associated timer output compare is disabled. input captures do not override the ddrt settings. bit 7654321bit 0 ddt7 ddt6 ddt5 ddt4 ddt3 ddt2 ddt1 ddt0 reset: 00000000 ddrt ? data direction register for timer port $00af f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 243 read: any time write: any time 16-bit pulse accumulator b (pacb) is formed by cascading the 8-bit pulse accumulators pac1 and pac0. when pben is set, the pacb is enabled. the pacb shares the input pin with ic0. pben ? pulse accumulator b system enable 0 = 16-bit pulse accumulator system disabled. 8-bit pac1 and pac0 can be enabled when their related enable bits in icpacr ($a8) are set. 1 = pulse accumulator b system enabled. the two 8-bit pulse accumulators pac1 and pac0 are cascaded to form the pacb 16-bit pulse accumulator. when pacb in enabled, the pacn1 and pacn0 registers contents are respectively the high and low byte of the pacb. pa1en and pa0en control bits in icpacr ($a8) have no effect. pben is independent from ten. with timer disabled, the pulse accumulator can still function unless pulse accumulator is disabled. pbovi ? pulse accumulator b overflow interrupt enable 0 = interrupt inhibited 1 = interrupt requested if pbovf is set bit 7654321bit 0 0 pben 0 0 0 0 pbovi 0 reset: 0 0 0 0 0 0 0 0 pbctl ? 16-bit pulse accumulator b control register $00b0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 244 enhanced capture timer motorola read: any time write: any time pbovf ? pulse accumulator b overflow flag this bit is set when the 16-bit pulse accumulator b overflows from $ffff to $0000, or when 8-bit pulse accumulator 1 (pac1) overflows from $ff to $00. this bit is cleared by a write to the pbflg register with bit 1 set. any access to the pacn1 and pacn0 registers will clear the pbovf flag in this register when tffca bit in register tscr($86) is set. read: any time write: has no effect. these registers are used to latch the value of the corresponding pulse accumulator when the related bits in register icpacr ($a8) are enabled (see pulse accumulators ). bit 7654321bit 0 000000pbovf0 reset:00000000 pbflg ? pulse accumulator b flag register $00b1 bit 7654321bit 0 $00b2bit 7654321bit 0pa3h $00b3bit 7654321bit 0pa2h $00b4bit 7654321bit 0pa1h $00b5bit 7654321bit 0pa0h reset:00000000 pa3h ? pa0h ? 8-bit pulse accumulators holding registers $00b2 ? $00b5 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer timer registers mc68hc912dg128 ? rev 3.0 technical data motorola enhanced capture timer 245 read: any time write: any time a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give different result than accessing them as a word. if the rdmcl bit in mcctl register is cleared, reads of the mccnt register will return the present value of the count register. if the rdmcl bit is set, reads of the mccnt will return the contents of the load register. if a $0000 is written into mccnt and modulus counter while latq and bufen in icsys ($ab) register are set, the input capture and pulse accumulator registers will be latched. with a $0000 write to the mccnt, the modulus counter will stay at zero and does not set the mczf flag in mcflg register. if modulus mode is enabled (modmc=1), a write to this address will update the load register with the value written to it. the count register will not be updated with the new value until the next counter underflow. the flmc bit in mcctl ($a6) can be used to immediately update the count register with the new value if an immediate load is desired. if modulus mode is not enabled (modmc=0), a write to this address will clear the prescaler and will immediately update the counter register with the value written to it and down-counts once to $0000. bit 7654321bit 0 $00b6 bit 15 14 13 12 11 10 9 bit 8 mccnth $00b7bit 7654321bit 0m ccntl reset: 1 1111111 mccnth/l ? modulus down-counter count register $00b6, $00b7 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 246 enhanced capture timer motorola read: any time write: has no effect. these registers are used to latch the value of the input capture registers tc0 ? tc3. the corresponding iosx bits in tios ($80) should be cleared (see ic channels ). bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc0h ? timer input capture holding register 0 $00b8 ? $00b9 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc1h ? timer input capture holding register 1 $00ba ? $00bb bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc2h ? timer input capture holding register 2 $00bc ? $00bd bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 bit 7654321bit 0 tc3h ? timer input capture holding register 3 $00be ? $00bf f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 247 enhanced capture timer motorola 13.5 timer and modulus counter operation in different modes stop: timer and modulus counter are off since clocks are stopped. bgdm: timer and modulus counter keep on running, unless tsbck (reg$86, bit5) is set to one. wait: counters keep on running, unless tswai in tscr ($86) is set to one. normal: timer and modulus counter keep on running, unless ten in tscr($86) respectively mcen in mcctl ($a6) are cleared. ten=0: all 16-bit timer operations are stopped, can only access the registers. mcen=0: modulus counter is stopped. paen=1: 16-bit pulse accumulator a is active. paen=0: 8-bit pulse accumulators 3 and 2 can be enabled. (see icpacr) pben=1: 16-bit pulse accumulator b is active. pben=0: 8-bit pulse accumulators 1 and 0 can be enabled. (see icpacr) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
enhanced capture timer technical data mc68hc912dg128 ? rev 3.0 248 enhanced capture timer motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 249 technical data ? mc68hc912dg128 section 14. multiple serial interface 14.1 contents 14.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 14.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 14.4 serial communication interface (sci) . . . . . . . . . . . . . . . . . . 250 14.5 serial peripheral interface (spi) . . . . . . . . . . . . . . . . . . . . . . . 262 14.6 port s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 14.2 introduction the multiple serial interface (msi) module consists of three independent serial i/o sub-systems: two serial communication interfaces (sci0 and sci1) and the serial peripheral interface (spi). each serial pin shares function with the general-purpose port pins of port s. the sci subsystems are nrz type systems that are compatible with standard rs-232 systems. these sci systems have a new single wire operation mode which allows the unused pin to be available as general-purpose i/o. the spi subsystem, which is compatible with the m68hc11 spi, includes new features such as ss output and bidirectional mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 250 multiple serial interface motorola 14.3 block diagram figure 14-1. multiple serial interface block diagram 14.4 serial communication interface (sci) two serial communication interfaces are available on the mc68hc912dg128. these are nrz format (one start, eight or nine data, and one stop bit) asynchronous communication systems with independent internal baud rate generation circuitry and sci transmitters and receivers. they can be configured for eight or nine data bits (one of which may be designated as a parity bit, odd or even). if enabled, parity is generated in hardware for transmitted and received data. receiver parity errors are flagged in hardware. the baud rate generator is based on a modulus counter, allowing flexibility in choosing baud rates. there is a receiver wake-up feature, an idle line detect feature, a loop-back mode, and various error detection features. two port pins for each sci provide the external interface for the transmitted data (txd) and the received data (rxd). for a faster wake-up out of wait mode by a received sci message, both sci have the capability of sending a receiver interrupt, if enabled, when raf (receiver active flag) is set. for compatibility with other m68hc12 products, this feature is active only in wait mode and is disabled when vddpll supply is at v ss level. ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 sci0 sci1 spi ddrs/ioctlr port s i/o drivers msi rxd0 txd0 rxd1 txd1 miso/siso mosi/momi sck cs /ss f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 251 figure 14-2. serial communications interface block diagram rx baud rate tx baud rate mclk divider 10-11 bit shift reg msb txd buffer/scxdrl txmtr control scxcr2/sci ctl 2 scxcr1/sci ctl 1 scxsr1/int status data recovery 10-11 bit shift reg txd buffer/scxdrl scxbd/select lsb rxd txd pin control / ddrs / port s wake-up logic scxcr1/sci ctl 1 scxsr1/int status scxcr2/sci ctl 2 int request logic msb lsb int request logic sci receiver sci transmitter baud rate clock to internal logic data bus parity detect parity generator f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 252 multiple serial interface motorola 14.4.1 data format the serial data format requires the following conditions:  an idle-line in the high state before transmission or reception of a message.  a start bit (logic zero), transmitted or received, that indicates the start of each character.  data that is transmitted or received least significant bit (lsb) first.  a stop bit (logic one), used to indicate the end of a frame. (a frame consists of a start bit, a character of eight or nine data bits and a stop bit.)  a break is defined as the transmission or reception of a logic zero for one frame or more.  this sci supports hardware parity for transmit and receive. 14.4.2 sci baud rate generation the basis of the sci baud rate generator is a 13-bit modulus counter. this counter gives the generator the flexibility necessary to achieve a reasonable level of independence from the cpu operating frequency and still be able to produce standard baud rates with a minimal amount of error. the clock source for the generator comes from the m clock. table 14-1. baud rate generation desired sci baud rate br divisor for m = 4.0 mhz br divisor for m = 8.0 mhz 110 2273 4545 300 833 2273 600 417 833 1200 208 417 2400 104 208 4800 52 104 9600 26 52 14400 17 35 19200 13 26 38400 ? 13 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 253 14.4.3 sci register descriptions control and data registers for the sci subsystem are described below. the memory address indicated for each register is the default address that is in use after reset. both sci have identical control registers mapped in two blocks of eight bytes. scxbdh and scxbdl are considered together as a 16-bit baud rate control register. read any time. write sbr[12:0] anytime. low order byte must be written for change to take effect. write sbr[15:13] only in special modes. the value in sbr[12:0] determines the baud rate of the sci. the desired baud rate is determined by the following formula: which is equivalent to: br is the value written to bits sbr[12:0] to establish baud rate. note: the baud rate generator is disabled until te or re bit in scxcr2 register is set for the first time after reset, and/or the baud rate generator is disabled when sbr[12:0] = 0. btst ? reserved for test function bspl ? reserved for test function brld ? reserved for test function bit 7654321bit 0 btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 high reset: 00000000 sc0bdh/sc1bdh ? sci baud rate control register $00c0/$00c8 bit 7654321bit 0 sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 low reset:00000100 sc0bdl/sc1bdl ? sci baud rate control register $00c1/$00c9 sci baud rate mclk 16 br -------------------- = br mclk 16 sci baud rate ----------------------------------------------- - = f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 254 multiple serial interface motorola read or write anytime. loops ? sci loop mode/single wire mode enable 0 = sci transmit and receive sections operate normally. 1 = sci receive section is disconnected from the rxd pin and the rxd pin is available as general purpose i/o. the receiver input is determined by the rsrc bit. the transmitter output is controlled by the associated ddrs bit. both the transmitter and the receiver must be enabled to use the loop or the single wire mode. if the ddrs bit associated with the txd pin is set during the loops = 1, the txd pin outputs the sci waveform. if the ddrs bit associated with the txd pin is clear during the loops = 1, the txd pin becomes high (idle line state) for rsrc = 0 and high impedance for rsrc = 1. refer to table 14-2 . woms ? wired-or mode for serial pins this bit controls the two pins (txd and rxd) associated with the scix section. 0 = pins operate in a normal mode with both high and low drive capability. to affect the rxd bit, that bit would have to be configured as an output (via dds0/2) which is the single wire case when using the sci. woms bit still affects general-purpose output on txd and rxd pins when scix is not using these pins. 1 = each pin operates in an open drain fashion if that pin is declared as an output . rsrc ? receiver source when loops = 1, the rsrc bit determines the internal feedback path for the receiver. 0 = receiver input is connected to the transmitter internally (not txd pin) 1 = receiver input is connected to the txd pin bit 7654321bit 0 loops woms rsrc m wake ilt pe pt reset: 0 0 0 0 0 0 0 0 sc0cr1/sc1cr1 ? sci control register 1 $00c2/$00ca f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 255 m ? mode (select character format) 0 = one start, eight data, one stop bit 1 = one start, eight data, ninth data, one stop bit wake ? wake-up by address mark/idle 0 = wake up by idle line recognition 1 = wake up by address mark (last data bit set) ilt ? idle line type determines which of two types of idle line detection will be used by the sci receiver. 0 = short idle line mode is enabled. 1 = long idle line mode is detected. in the short mode, the sci circuitry begins counting ones in the search for the idle line condition immediately after the start bit. this means that the stop bit and any bits that were ones before the stop bit could be counted in that string of ones, resulting in earlier recognition of an idle line. in the long mode, the sci circuitry does not begin counting ones in the search for the idle line condition until a stop bit is received. therefore, the last byte ? s stop bit and preceding ? 1 ? bits do not affect how quickly an idle line condition can be detected. pe ? parity enable 0 = parity is disabled. 1 = parity is enabled. table 14-2. loop mode functions loops rsrc ddsi(3) woms function of port s bit 1/3 0 x x x normal operations 1 0 0 0/1 loop mode without txd output(txd = high impedance) 1 0 1 1 loop mode with txd output (cmos) 1 0 1 1 loop mode with txd output (open-drain) 11 0 x single wire mode without txd output (the pin is used as receiver input only, txd = high impedance) 11 1 0 single wire mode with txd output (the output is also fed back to receiver input, cmos) 1 1 1 1 single wire mode for the receiving and transmitting(open-drain) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 256 multiple serial interface motorola pt ? parity type if parity is enabled, this bit determines even or odd parity for both the receiver and the transmitter. 0 = even parity is selected. an even number of ones in the data character causes the parity bit to be zero and an odd number of ones causes the parity bit to be one. 1 = odd parity is selected. an odd number of ones in the data character causes the parity bit to be zero and an even number of ones causes the parity bit to be one. read or write anytime. tie ? transmit interrupt enable 0 = tdre interrupts disabled 1 = sci interrupt will be requested whenever the tdre status flag is set. tcie ? transmit complete interrupt enable 0 = tc interrupts disabled 1 = sci interrupt will be requested whenever the tc status flag is set. rie ? receiver interrupt enable 0 = rdrf and or interrupts disabled, raf interrupt in wait mode disabled 1 = sci interrupt will be requested whenever the rdrf or or status flag is set, or when raf is set while in wait mode with vddpll high. ilie ? idle line interrupt enable 0 = idle interrupts disabled 1 = sci interrupt will be requested whenever the idle status flag is set. bit 7654321bit 0 tie tcie rie ilie te re rwu sbk reset: 00000000 sc0cr2/sc1cr2 ? sci control register 2 $00c3/$00cb f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 257 te ? transmitter enable 0 = transmitter disabled 1 = sci transmit logic is enabled and the txd pin (port s bit 1/bit 3) is dedicated to the transmitter. the te bit can be used to queue an idle preamble. re ? receiver enable 0 = receiver disabled 1 = enables the sci receive circuitry. rwu ? receiver wake-up control 0 = normal sci receiver 1 = enables the wake-up function and inhibits further receiver interrupts. normally hardware wakes the receiver by automatically clearing this bit. sbk ? send break 0 = break generator off 1 = generate a break code (at least 10 or 11 contiguous zeros). as long as sbk remains set the transmitter will send zeros. when sbk is changed to zero, the current frame of all zeros is finished before the txd line goes to the idle state. if sbk is toggled on and off, the transmitter will send only 10 (or 11) zeros and then revert to mark idle or sending data. the bits in these registers are set by various conditions in the sci hardware and are automatically cleared by special acknowledge sequences. the receive related flag bits in scxsr1 (rdrf, idle, or, nf, fe, and pf) are all cleared by a read of the scxsr1 register followed by a read of the transmit/receive data register low byte. however, only those bits which were set when scxsr1 was read will be bit 7654321bit 0 tdre tc rdrf idle or nf fe pf reset: 11000000 sc0sr1/sc1sr1 ? sci status register 1 $00c4/$00cc f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 258 multiple serial interface motorola cleared by the subsequent read of the transmit/receive data register low byte. the transmit related bits in scxsr1 (tdre and tc) are cleared by a read of the scxsr1 register followed by a write to the transmit/receive data registerl low byte. read anytime (used in auto clearing mechanism). write has no meaning or effect. tdre ? transmit data register empty flag new data will not be transmitted unless scxsr1 is read before writing to the transmit data register. reset sets this bit. 0 = scxdr busy 1 = any byte in the transmit data register is transferred to the serial shift register so new data may now be written to the transmit data register. tc ? transmit complete flag flag is set when the transmitter is idle (no data, preamble, or break transmission in progress). clear by reading scxsr1 with tc set and then writing to scxdr. 0 = transmitter busy 1 = transmitter is idle rdrf ? receive data register full flag once cleared, idle is not set again until the rxd line has been active and becomes idle again. rdrf is set if a received character is ready to be read from scxdr. clear the rdrf flag by reading scxsr1 with rdrf set and then reading scxdr. 0 = scxdr empty 1 = scxdr full idle ? idle line detected flag receiver idle line is detected (the receipt of a minimum of 10/11 consecutive ones). this bit will not be set by the idle line condition when the rwu bit is set. once cleared, idle will not be set again until after rdrf has been set (after the line has been active and becomes idle again). 0 = rxd line is idle 1 = rxd line is active f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 259 or ? overrun error flag new byte is ready to be transferred from the receive shift register to the receive data register and the receive data register is already full (rdrf bit is set). data transfer is inhibited until this bit is cleared. 0 = no overrun 1 = overrun detected nf ? noise error flag set during the same cycle as the rdrf bit but not set in the case of an overrun (or). 0 = unanimous decision 1 = noise on a valid start bit, any of the data bits, or on the stop bit fe ? framing error flag set when a zero is detected where a stop bit was expected. clear the fe flag by reading scxsr1 with fe set and then reading scxdr. 0 = stop bit detected 1 = zero detected rather than a stop bit pf ? parity error flag indicates if received data ? s parity matches parity bit. this feature is active only when parity is enabled. the type of parity tested for is determined by the pt (parity type) bit in scxcr1. 0 = parity correct 1 = incorrect parity detected f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 260 multiple serial interface motorola read anytime. write has no meaning or effect. raf ? receiver active flag this bit is controlled by the receiver front end. it is set during the rt1 time period of the start bit search. it is cleared when an idle state is detected or when the receiver circuitry detects a false start bit (generally due to noise or baud rate mismatch). 0 = a character is not being received 1 = a character is being received if enabled with rie = 1, raf set generates an interrupt when vddpll is high while in wait mode. bit 7654321bit 0 0i000000raf reset: 0 0 000000 sc0sr2/sc1sr2 ? sci status register 2 $00c5/$00cd bit 7654321bit 0 r8t8000000 reset: ???????? sc0drh/sc1drh ? sci data register high $00c6/$00ce bit 7654321bit 0 r7/t7 r6/t6 r5/t5 r4/t4 r3/t3 r2/t2 r1/t1 r0/t0 reset: ???????? sc0drl/sc1drl ? sci data register low $00c7/$00cf bit 7654321bit 0 r8t8000000 reset: ???????? sc0drh/sc1drh ? sci data register high $00c6/$00ce f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial communication interface (sci) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 261 r8 ? receive bit 8 read anytime. write has no meaning or affect. this bit is the ninth serial data bit received when the sci system is configured for nine-data-bit operation. t8 ? transmit bit 8 read or write anytime. this bit is the ninth serial data bit transmitted when the sci system is configured for nine-data-bit operation. when using 9-bit data format this bit does not have to be written for each data word. the same value will be transmitted as the ninth bit until this bit is rewritten. r7/t7 ? r0/t0 ? receive/transmit data bits 7 to 0 reads access the eight bits of the read-only sci receive data register (rdr). writes access the eight bits of the write-only sci transmit data register (tdr). scxdrl:scxdrh form the 9-bit data word for the sci. if the sci is being used with a 7- or 8-bit data word, only scxdrl needs to be accessed. if a 9-bit format is used, the upper register should be written first to ensure that it is transferred to the transmitter shift register with the lower register. bit 7654321bit 0 r7/t7 r6/t6 r5/t5 r4/t4 r3/t3 r2/t2 r1/t1 r0/t0 reset: ???????? sc0drl/sc1drl ? sci data register low $00c7/$00cf f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 262 multiple serial interface motorola 14.5 serial peripheral interface (spi) the serial peripheral interface allows the mc68hc912dg128 to communicate synchronously with peripheral devices and other microprocessors. the spi system in the mc68hc912dg128 can operate as a master or as a slave. the spi is also capable of interprocessor communications in a multiple master system. when the spi is enabled, all pins that are defined by the configuration as inputs will be inputs regardless of the state of the ddrs bits for those pins. all pins that are defined as spi outputs will be outputs only if the ddrs bits for those pins are set. any spi output whose corresponding ddrs bit is cleared can be used as a general-purpose input. a bidirectional serial pin is possible using the ddrs as the direction control. 14.5.1 spi baud rate generation the e clock is input to a divider series and the resulting spi clock rate may be selected to be e divided by 2, 4, 8, 16, 32, 64, 128 or 256. three bits in the sp0br register control the spi clock rate. this baud rate generator is activated only when spi is in the master mode and serial transfer is taking place. otherwise this divider is disabled to save power. 14.5.2 spi operation in the spi system the 8-bit data register in the master and the 8-bit data register in the slave are linked to form a distributed 16-bit register. when a data transfer operation is performed, this 16-bit register is serially shifted eight bit positions by the sck clock from the master so the data is effectively exchanged between the master and the slave. data written to the sp0dr register of the master becomes the output data for the slave and data read from the sp0dr register of the master after a transfer operation is the input data from the slave. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial peripheral interface (spi) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 263 figure 14-3. serial peripheral interface block diagram a clock phase control bit (cpha) and a clock polarity control bit (cpol) in the sp0cr1 register select one of four possible clock formats to be used by the spi system. the cpol bit simply selects non-inverted or inverted clock. the cpha bit is used to accommodate two fundamentally different protocols by shifting the clock by one half cycle or no phase shift. pin control logic 8-bit shift register read data buffer shift control logic clock logic spi control sp0sr spi status register sp0dr spi data register spif wcol modf divider select sp0br spi baud rate register 2 4 8 16 32 64 128 256 spi interrupt internal bus mcu p clock (same as e rate) s m m s m s spr2 spr1 spr0 request spie spe mstr cpol cpha lsbf lsbf pups rds swom spc0 ssoe spe clock mstr swom miso ps4 sck ps6 ss ps7 mosi ps5 sp0cr1 spi control register 1 sp0cr2 spi control register 2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 264 multiple serial interface motorola figure 14-4. spi clock format 0 (cpha = 0) t l begin end sck (cpol=0) sample i change o sel ss (o) transfer sck (cpol=1) msb first (lsbf=0): lsb first (lsbf=1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) (mosi pin) (miso pin) (master only) (mosi/miso) t t if next transfer begins here for t t , t l , t l minimum 1/2 sck t i t l f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial peripheral interface (spi) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 265 figure 14-5. spi clock format 1 (cpha = 1) 14.5.3 ss output available in master mode only, ss output is enabled with the ssoe bit in the sp0cr1 register if the corresponding ddrs is set. the ss output pin will be connected to the ss input pin of the external slave device. the ss output automatically goes low for each transmission to select the external device and it goes high during each idling state to deselect external devices. t l t t for t t , t l , t l minimum 1/2 sck t i t l if next transfer begins here begin end sck (cpol=0) sample i change o sel ss (o) transfer sck (cpol=1) msb first (lsbf=0): lsb first (lsbf=1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) (mosi pin) (miso pin) (master only) (mosi/miso) table 14-3. ss output selection dds7 ssoe master mode slave mode 00ss input with modf feature ss input 01 reserved ss input 1 0 general-purpose output ss input 11 ss output ss input f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 266 multiple serial interface motorola 14.5.4 bidirectional mode (momi or siso) in bidirectional mode, the spi uses only one serial data pin for external device interface. the mstr bit decides which pin to be used. the mosi pin becomes serial data i/o (momi) pin for the master mode, and the miso pin becomes serial data i/o (siso) pin for the slave mode. the direction of each serial i/o pin depends on the corresponding ddrs bit. when spe=1 master mode mstr=1 slave mode mstr=0 normal mode spc0=0 swom enables open drain output. swom enables open drain output. bidirectional mode spc0=1 swom enables open drain output. ps4 becomes gpio. swom enables open drain output. ps5 becomes gpio. figure 14-6. normal mode and bidirectional mode spi mo mi ddrs5 serial out serial in spi mo mi dds5 serial out serial in spi si so serial in serial out ddrs4 spi si so serial in serial out dds4 spi momi ps4 ddrs5 serial out serial in spi momi ps4 dds5 serial out serial in spi ps5 siso ddrs4 serial in serial out spi ps5 siso dds4 serial in serial out f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial peripheral interface (spi) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 267 14.5.5 register descriptions control and data registers for the spi subsystem are described below. the memory address indicated for each register is the default address that is in use after reset. for more information refer to operating modes . read or write anytime. spie ? spi interrupt enable 0 = spi interrupts are inhibited 1 = hardware interrupt sequence is requested each time the spif or modf status flag is set spe ? spi system enable 0 = spi internal hardware is initialized and spi system is in a low- power disabled state. 1 = ps[4:7] are dedicated to the spi function when modf is set, spe always reads zero. sp0cr1 must be written as part of a mode fault recovery sequence. swom ? port s wired-or mode controls not only spi output pins but also the general-purpose output pins (ps[4:7]) which are not used by spi. 0 = spi and/or ps[4:7] output buffers operate normally 1 = spi and/or ps[4:7] output buffers behave as open-drain outputs mstr ? spi master/slave mode select 0 = slave mode 1 = master mode when modf is set, mstr always reads zero. sp0cr1 must be written as part of a mode fault recovery sequence. bit 7654321bit 0 spie spe swom mstr cpol cpha ssoe lsbf reset: 00000100 sp0cr1 ? spi control register 1 $00d0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 268 multiple serial interface motorola cpol, cpha ? spi clock polarity, clock phase these two bits are used to specify the clock format to be used in spi operations. when the clock polarity bit is cleared and data is not being transferred, the sck pin of the master device is low. when cpol is set, sck idles high. see figure 14-4 and figure 14-5 . ssoe ? slave select output enable the ss output feature is enabled only in the master mode by asserting the ssoe and dds7. lsbf ? spi lsb first enable 0 = data is transferred most significant bit first 1 = data is transferred least significant bit first normally data is transferred most significant bit first.this bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register will always have msb in bit 7. read or write anytime. pups ? pull-up port s enable 0 = no internal pull-ups on port s 1 = all port s input pins have an active pull-up device. if a pin is programmed as output, the pull-up device becomes inactive rdps ? reduce drive of port s 0 = port s output drivers operate normally 1 = all port s output pins have reduced drive capability for lower power and less noise spswai ? serial interface stop in wait mode 0 = serial interface clock operates normally 1 = halt serial interface clock generation in wait mode sp0cr2 ? spi control register 2 $00d1 bit 7654321bit 0 0 0 0 0 pups rdps spswai spc0 reset: 0 0001000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface serial peripheral interface (spi) mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 269 spc0 ? serial pin control 0 this bit decides serial pin configurations with mstr control bit. read anytime. write anytime. at reset, e clock divided by 2 is selected. spr[2:0] ? spi clock (sck) rate select bits these bits are used to specify the spi clock rate. pin mode spc0 (1) mstr miso (2) mosi (3) sck (4) ss (5) #1 normal 0 0 slave out slave in sck in ss in #2 1 master in master out sck out ss i/o #3 bidirectional 1 0 slave i/o gpi/o sck in ss in #4 1 gpi/o master i/o sck out ss i/o 1. the serial pin control 0 bit enables bidirectional configurations. 2. slave output is enabled if dds4 = 1, ss = 0 and mstr = 0. (#1, #3) 3. master output is enabled if dds5 = 1 and mstr = 1. (#2, #4) 4. sck output is enabled if dds6 = 1 and mstr = 1. (#2, #4) 5. ss output is enabled if dds7 = 1, ssoe = 1 and mstr = 1. (#2, #4) bit 7654321bit 0 0 0 0 0 0 spr2 spr1 spr0 reset: 0 0 0 0 0 0 0 0 sp0br ? spi baud rate register $00d2 table 14-4. spi clock rate selection spr2 spr1 spr0 e clock divisor frequency at e clock = 4 mhz frequency at e clock = 8 mhz 0 0 0 2 2.0 mhz 4.0 mhz 0 0 1 4 1.0 mhz 2.0 mhz 0 1 0 8 500 khz 1.0 mhz 0 1 1 16 250 khz 500 khz 1 0 0 32 125 khz 250 khz 1 0 1 64 62.5 khz 125 khz 1 1 0 128 31.3 khz 62.5 khz 1 1 1 256 15.6 khz 31.3 khz f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 270 multiple serial interface motorola read anytime. write has no meaning or effect. spif ? spi interrupt request spif is set after the eighth sck cycle in a data transfer and it is cleared by reading the sp0sr register (with spif set) followed by an access (read or write) to the spi data register. wcol ? write collision status flag the mcu write is disabled to avoid writing over the data being transferred. no interrupt is generated because the error status flag can be read upon completion of the transfer that was in progress at the time of the error. automatically cleared by a read of the sp0sr (with wcol set) followed by an access (read or write) to the sp0dr register. 0 = no write collision 1 = indicates that a serial transfer was in progress when the mcu tried to write new data into the sp0dr data register. modf ? spi mode error interrupt status flag this bit is set automatically by spi hardware if the mstr control bit is set and the slave select input pin becomes zero. this condition is not permitted in normal operation. in the case where ddrs bit 7 is set, the ps7 pin is a general-purpose output pin or ss output pin rather than being dedicated as the ss input for the spi system. in this special case the mode fault function is inhibited and modf remains cleared. this flag is automatically cleared by a read of the sp0sr (with modf set) followed by a write to the sp0cr1 register. bit 7654321bit 0 spif wcol 0 modf 0 0 0 0 reset: 0 0 000000 sp0sr ? spi status register $00d3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface port s mc68hc912dg128 ? rev 3.0 technical data motorola multiple serial interface 271 read anytime (normally only after spif flag set). write anytime (see wcol write collision flag). reset does not affect this address. this 8-bit register is both the input and output register for spi data. reads of this register are double buffered but writes cause data to be written directly into the serial shifter. in the spi system the 8-bit data register in the master and the 8-bit data register in the slave are linked by the mosi and miso wires to form a distributed 16-bit register. when a data transfer operation is performed, this 16-bit register is serially shifted eight bit positions by the sck clock from the master so the data is effectively exchanged between the master and the slave. note that some slave devices are very simple and either accept data from the master without returning data to the master or pass data to the master without requiring data from the master. 14.6 port s in all modes, port s bits ps[7:0] can be used for either general-purpose i/o, or with the sci and spi subsystems. during reset, port s pins are configured as high-impedance inputs (ddrs is cleared). read anytime (inputs return pin level; outputs return pin driver input level). write data stored in internal latch (drives pins only if configured for output). writes do not change pin state when pin configured for spi or sci output. bit 7654321bit 0 bit 7654321bit 0 sp0dr ? spi data register $00d5 ports ? port s data register $00d6 bit 7654321bit 0 ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 pin function ss cs sck mosi momi miso siso txd1 rxd1 txd0 rxd0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
multiple serial interface technical data mc68hc912dg128 ? rev 3.0 272 multiple serial interface motorola after reset all bits are configured as general-purpose inputs. port s shares function with the on-chip serial systems (spi and sci0/1). read or write anytime. after reset, all general-purpose i/o are configured for input only. 0 = configure the corresponding i/o pin for input only 1 = configure the corresponding i/o pin for output dds2, dds0 ? data direction for port s bit 2 and bit 0 if the sci receiver is configured for two-wire sci operation, corresponding port s pins will be input regardless of the state of these bits. dds3, dds1 ? data direction for port s bit 3 and bit 1 if the sci transmitter is configured for two-wire sci operation, corresponding port s pins will be output regardless of the state of these bits. dds[6:4] ? data direction for port s bits 6 through 4 if the spi is enabled and expects the corresponding port s pin to be an input, it will be an input regardless of the state of the ddrs bit. if the spi is enabled and expects the bit to be an output, it will be an output only if the ddrs bit is set. dds7 ? data direction for port s bit 7 in spi slave mode, ddrs7 has no meaning or effect; the ps7 pin is dedicated as the ss input. in spi master mode, ddrs7 determines whether ps7 is an error detect input to the spi or a general-purpose or slave select output line. note: if mode fault error occurs, bits 5, 6 and 7 are forced to zero. . bit 7654321bit 0 dds7 dds6 dds5 dds4 dds3 dds2 dds1 dds0 reset: 0 0 000000 ddrs ? data direction register for port s $00d7 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 273 technical data ? mc68hc912dg128 section 15. inter-ic bus 15.1 contents 15.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 15.3 iic features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 15.4 iic system configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 15.5 iic protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 15.6 iic register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 15.7 iic programming examples . . . . . . . . . . . . . . . . . . . . . . . . . .290 15.2 introduction the inter-ic bus (iic or i 2 c) is a two-wire, bidirectional serial bus that provides a simple, efficient method of data exchange between devices. being a two-wire device, the iic minimizes the need for large numbers of connections between devices, and eliminates the need for an address decoder. this bus is suitable for applications requiring occasional communications over a short distance between a number of devices. it also provides flexibility, allowing additional devices to be connected to the bus for further expansion and system development. the interface is designed to operate up to 100kbps with maximum bus loading and timing. the device is capable of operating at higher baud rates, up to a maximum of clock/20, with reduced bus loading. the maximum communication length and the number of devices that can be connected are limited by a maximum bus capacitance of 400pf. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 274 inter-ic bus motorola 15.3 iic features the iic module has the following key features:  compatible with i 2 c bus standard  multi-master operation  software programmable for one of 64 different serial clock frequencies  software selectable acknowledge bit  interrupt driven byte-by-byte data transfer  arbitration lost interrupt with automatic mode switching from master to slave  calling address identification interrupt  start and stop signal generation/detection  repeated start signal generation  acknowledge bit generation/detection  bus busy detection  eight-bit general purpose i/o port a block diagram of the iic module is shown in figure 15-1 . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic features mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 275 figure 15-1. iic block diagram input sync in/out data shift register address compare scl sda interrupt addr & control data clock control start, stop & arbitration co n t r ol ctrl_reg freq_reg addr_reg status_reg data_reg addr_decode data_mux f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 276 inter-ic bus motorola 15.4 iic system configuration the iic system uses a serial data line (sda) and a serial clock line (scl) for data transfer. all devices connected to it must have open drain or open collector outputs. logic ? and ? function is exercised on both lines with external pull-up resistors, the value of these resistors is system dependent. 15.5 iic protocol normally, a standard communication is composed of four parts: start signal, slave address transmission, data transfer and stop signal. they are described briefly in the following sections and illustrated in figure 15- 2 . figure 15-2. iic transmission signals scl sda start signal ack bit 1 2 34 5 6 78 msb lsb 1 2 34 5 6 78 msb lsb stop signal no scl sda 1234567 8 msb lsb 1 2 5 678 msb lsb repeated 34 9 9 ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w xxx d7 d6 d5 d4 d3 d2 d1 d0 calling address read/ data byte ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w new calling address 99 xx ack bit write start signal start signal ack bit calling address read/ write stop signal no ack bit read/ write f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic protocol mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 277 15.5.1 start signal when the bus is free, i.e. no master device is engaging the bus (both scl and sda lines are at logical high), a master may initiate communication by sending a start signal. as shown in figure 15-2 , a start signal is defined as a high-to-low transition of sda while scl is high. this signal denotes the beginning of a new data transfer (each data transfer may contain several bytes of data) and wakes up all slaves. 15.5.2 slave address transmission the first byte of data transfer immediately after the start signal is the slave address transmitted by the master. this is a seven-bit calling address followed by a r/w bit. the r/w bit tells the slave the desired direction of data transfer. 1 = read transfer, the slave transmits data to the master. 0 = write transfer, the master transmits data to the slave. only the slave with a calling address that matches the one transmitted by the master will respond by sending back an acknowledge bit. this is done by pulling the sda low at the 9th clock (see figure 15-2 ). slave address - no two slaves in the system may have the same address. if the iic is master, it must not transmit an address that is equal to its own slave address. the iic cannot be master and slave at the same time. if however arbitration is lost during an address cycle the iic will revert to slave mode and operate correctly even if it is being addressed by another master. 15.5.3 data transfer once successful slave addressing is achieved, the data transfer can proceed byte-by-byte in a direction specified by the r/w bit sent by the calling master. note: all transfers that come after an address cycle are referred to as data transfers, even if they carry sub-address information for the slave device. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 278 inter-ic bus motorola each data byte is 8 bits long. data may be changed only while scl is low and must be held stable while scl is high as shown in figure 15-2 . there is one clock pulse on scl for each data bit, the msb being transferred first. each data byte has to be followed by an acknowledge bit, which is signalled from the receiving device by pulling the sda low at the ninth clock. so one complete data byte transfer needs nine clock pulses. if the slave receiver does not acknowledge the master, the sda line must be left high by the slave. the master can then generate a stop signal to abort the data transfer or a start signal (repeated start) to commence a new calling. if the master receiver does not acknowledge the slave transmitter after a byte transmission, it means ? end of data ? to the slave, so the slave releases the sda line for the master to generate stop or start signal. 15.5.4 stop signal the master can terminate the communication by generating a stop signal to free the bus. however, the master may generate a start signal followed by a calling command without generating a stop signal first. this is called repeated start. a stop signal is defined as a low- to-high transition of sda while scl at logical ? 1 ? (see figure 15-2 ). the master can generate a stop even if the slave has generated an acknowledge at which point the slave must release the bus. 15.5.5 repeated start signal as shown in figure 15-2 , a repeated start signal is a start signal generated without first generating a stop signal to terminate the communication. this is used by the master to communicate with another slave or with the same slave in different mode (transmit/receive mode) without releasing the bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic protocol mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 279 15.5.6 arbitration procedure iic is a true multi-master bus that allows more than one master to be connected on it. if two or more masters try to control the bus at the same time, a clock synchronization procedure determines the bus clock, for which the low period is equal to the longest clock low period and the high is equal to the shortest one among the masters. the relative priority of the contending masters is determined by a data arbitration procedure, a bus master loses arbitration if it transmits logic ? 1 ? while another master transmits logic ? 0 ? . the losing masters immediately switch over to slave receive mode and stop driving sda output. in this case the transition from master to slave mode does not generate a stop condition. meanwhile, a status bit is set by hardware to indicate loss of arbitration. 15.5.7 clock synchronization since wire-and logic is performed on scl line, a high-to-low transition on scl line affects all the devices connected on the bus. the devices start counting their low period and once a device ? s clock has gone low, it holds the scl line low until the clock high state is reached. however, the change of low to high in this device clock may not change the state of the scl line if another device clock is still within its low period. therefore, synchronized clock scl is held low by the device with the longest low period. devices with shorter low periods enter a high wait state during this time (see figure 15-3 ). when all devices concerned have counted off their low period, the synchronized clock scl line is released and pulled high. there is then no difference between the device clocks and the state of the scl line and all the devices start counting their high periods. the first device to complete its high period pulls the scl line low again. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 280 inter-ic bus motorola figure 15-3. iic clock synchronization 15.5.8 handshaking the clock synchronization mechanism can be used as a handshake in data transfer. slave devices may hold the scl low after completion of one byte transfer (9 bits). in such case, it halts the bus clock and forces the master clock into wait states until the slave releases the scl line. 15.5.9 clock stretching the clock synchronization mechanism can be used by slaves to slow down the bit rate of a transfer. after the master has driven scl low the slave can drive scl low for the required period and then release it. if the slave scl low period is greater than the master scl low period then the resulting scl bus signal low period is stretched. scl1 scl2 scl internal counter reset wait start counting high period f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic register descriptions mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 281 15.6 iic register descriptions . read and write anytime this register contains the address the iic will respond to when addressed as a slave; note that it is not the address sent on the bus during the address transfer adr7 ? adr1 ? slave address bit 1 to bit 7 contain the specific slave address to be used by the iic module. the default mode of iic is slave mode for an address match on the bus. read and write anytime ibc5 ? ibc0 ? iic bus clock rate 5 ? 0 this field is used to prescale the clock for bit rate selection. the bit clock generator is implemented as a prescaled shift register - ibc5-3 select the prescaler divider and ibc2-0 select the shift register tap point. the ibc bits are decoded to give the tap and prescale values as shown in table 15-1 . ibad ? iic bus address register $00e0 bit 7654321bit 0 adr7 adr6 adr5 adr4 adr3 adr2 adr1 0 reset: 0 0 0 0 0 0 0 0 ibfd ? iic bus frequency divider register $00e1 bit 7654321bit 0 00 ibc5 ibc4 ibc3 ibc2 ibc1 ibc0 reset: 0 0000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 282 inter-ic bus motorola the number of clocks from the falling edge of scl to the first tap (tap[1]) is defined by the values shown in the scl2tap column of table 15-1 , all subsequent tap points are separated by 2 ibc5-3 as shown in the tap2tap column in table 15-1 . the scl tap is used to generated the scl period and the sda tap is used to determine the delay from the falling edge of scl to sda changing, the sda hold time. the serial bit clock frequency is equal to the cpu clock frequency divided by the divider shown in table 15-2 . the equation used to generate the divider values from the ibfd bits is: scl divider = 2 x ( scl2tap + [ ( scl_tap -1 ) x tap2tap ] + 2 ) the sda hold delay is equal to the cpu clock period multiplied by the sda hold value shown in figure 15-2 . the equation used to generate the sda hold value from the ibfd bits is: sda hold = scl2tap + [ ( sda_tap - 1 ) x tap2tap ] + 3 table 15-1. iic tap and prescale values ibc2-0 (bin) scl tap (clocks) sda tap (clocks) ibc5-3 (bin) scl2tap (clocks) tap2tap (clocks) 000 5 1 000 4 1 001 6 1 001 4 2 010 7 2 010 6 4 011 8 2 011 6 8 100 9 3 100 14 16 101 10 3 101 30 32 110 12 4 110 62 64 111 15 4 111 126 128 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic register descriptions mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 283 table 15-2. iic divider and sda hold values ibc5-0 (hex) scl divider (clocks) sda hold (clocks) ibc5-0 (hex) scl divider (clocks) sda hold (clocks) 00 20 7 20 160 17 01 22 7 21 192 17 02 24 8 22 224 33 03 26 8 23 256 33 04 28 9 24 288 49 05 30 9 25 320 49 06 34 10 26 384 65 07 40 10 27 480 65 08 28 7 28 320 33 09 32 7 29 384 33 0a 36 9 2a 448 65 0b 40 9 2b 512 65 0c 44 11 2c 576 97 0d 48 11 2d 640 97 0e 56 13 2e 768 129 0f 68 13 2f 960 129 10 48 9 30 640 65 11 56 9 31 768 65 12 64 13 32 896 129 13 72 13 33 1024 129 14 80 17 34 1152 193 15 88 17 35 1280 193 16 104 21 36 1536 257 17 128 21 37 1920 257 18 80 9 38 1280 129 19 96 9 39 1536 129 1a 112 17 3a 1792 257 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 284 inter-ic bus motorola read and write anytime iben ? iic bus enable this bit controls the software reset of the entire iic module. 0 = the module is reset and disabled. this is the power-on reset situation. when low the iic system is held in reset but registers can still be accessed. 1 = the iic system is enabled. this bit must be set before any other ibcr bits have any effect. if the iic module is enabled in the middle of a byte transfer the interface behaves as follows: slave mode ignores the current transfer on the bus and starts operating whenever a subsequent start condition is detected. master mode will not be aware that the bus is busy, hence if a start cycle is initiated then the current bus cycle may become corrupt. this would ultimately result in either the current bus master or the iic module losing arbitration, after which bus operation would return to normal. ibie ? iic bus interrupt enable 0 = interrupts from the iic module are disabled. note that this does not clear any currently pending interrupt condition. 1 = interrupts from the iic module are enabled. an iic interrupt occurs provided the ibif bit in the status register is also set. 1b 128 17 3b 2048 257 1c 144 25 3c 2304 385 1d 160 25 3d 2560 385 1e 192 33 3e 3072 513 1f 240 33 3f 3840 513 table 15-2. iic divider and sda hold values ibc5-0 (hex) scl divider (clocks) sda hold (clocks) ibc5-0 (hex) scl divider (clocks) sda hold (clocks) ibcr ? iic bus control register $00e2 bit 7654321bit 0 iben ibie ms/sl tx/rx txak rsta 0 ibswai reset: 00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic register descriptions mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 285 ms/sl ? master/slave mode select bit upon reset, this bit is cleared. when this bit is changed from 0 to 1, a start signal is generated on the bus, and the master mode is selected. when this bit is changed from 1 to 0, a stop signal is generated and the operation mode changes from master to slave. ms/sl is cleared without generating a stop signal when the master loses arbitration. 0 = slave mode 1 = master mode tx/rx ? transmit/receive mode select bit this bit selects the direction of master and slave transfers. when addressed as a slave this bit should be set by software according to the srw bit in the status register. in master mode this bit should be set according to the type of transfer required. therefore, for address cycles, this bit will always be high. 0 = receive 1 = transmit txak ? transmit acknowledge enable this bit specifies the value driven onto sda during acknowledge cycles for both master and slave receivers. note that values written to this bit are only used when the iic is a receiver, not a transmitter. 0 = an acknowledge signal will be sent out to the bus at the 9th clock bit after receiving one byte data 1 = no acknowledge signal response is sent (i.e., acknowledge bit = 1) rsta ? repeat start writing a 1 to this bit will generate a repeated start condition on the bus, provided it is the current bus master. this bit will always be read as a low. attempting a repeated start at the wrong time, if the bus is owned by another master, will result in loss of arbitration. 1 = generate repeat start cycle ibswai ? iic stop in wait mode 0 = iic module operates normally 1 = halt clock generation of iic module in wait mode f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 286 inter-ic bus motorola this status register is read-only with exception of bit 1 (ibif) and bit 4 (ibal), which are software clearable tcf ? data transferring bit while one byte of data is being transferred, this bit is cleared. it is set by the falling edge of the 9th clock of a byte transfer. 0 = transfer in progress 1 = transfer complete iaas ? addressed as a slave bit when its own specific address (iic bus address register) is matched with the calling address, this bit is set. the cpu is interrupted provided the ibie is set. then the cpu needs to check the srw bit and set its tx/rx mode accordingly. writing to the iic bus control register clears this bit. 0 = not addressed 1 = addressed as a slave ibb ? iic bus busy bit this bit indicates the status of the bus. when a start signal is detected, the ibb is set. if a stop signal is detected, it is cleared. 0 = bus is idle 1 = bus is busy ibal ? arbitration lost the arbitration lost bit (ibal) is set by hardware when the arbitration procedure is lost. arbitration is lost in the following circumstances: 1. sda sampled as low when the master drives a high during an address or data transmit cycle. 2. sda sampled as a low when the master drives a high during the acknowledge bit of a data receive cycle. 3. a start cycle is attempted when the bus is busy. 4. a repeated start cycle is requested in slave mode. ibsr ? iic bus status register $00e3 bit 76 5 4 3 2 1bit 0 tcf iaas ibb ibal 0 srw ibif rxak reset: 1 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic register descriptions mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 287 5. a stop condition is detected when the master did not request it. this bit must be cleared by software, by writing a one to it. srw ? slave read/write when iaas is set this bit indicates the value of the r/w command bit of the calling address sent from the master. caution: this bit is only valid when the iic is in slave mode, a complete address transfer has occurred with an address match and no other transfers have been initiated. checking this bit, the cpu can select slave transmit/receive mode according to the command of the master. 0 = slave receive, master writing to slave 1 = slave transmit, master reading from slave ibif ? iic bus interrupt flag the ibif bit is set when an interrupt is pending, which will cause a processor interrupt request provided ibie is set. ibif is set when one of the following events occurs: 1. complete one byte transfer (set at the falling edge of the 9th clock). 2. receive a calling address that matches its own specific address in slave receive mode. 3. arbitration lost. this bit must be cleared by software, writing a one to it, in the interrupt routine. rxak ? received acknowledge the value of sda during the acknowledge bit of a bus cycle. if the received acknowledge bit (rxak) is low, it indicates an acknowledge signal has been received after the completion of 8 bits data transmission on the bus. if rxak is high, it means no acknowledge signal is detected at the 9th clock. 0 = acknowledge received 1 = no acknowledge received f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 288 inter-ic bus motorola . read and write anytime in master transmit mode, when data is written to the ibdr a data transfer is initiated. the most significant bit is sent first. in master receive mode, reading this register initiates next byte data receiving. in slave mode, the same functions are available after an address match has occurred. note: in master transmit mode, the first byte of data written to ibdr following assertion of ms/sl is used for the address transfer and should comprise of the calling address (in position d7-d1) concatenated with the required r/w bit (in position d0). read and write anytime rdpib ? reduced drive of port ib 0 = all port ib output pins have full drive enabled. 1 = all port ib output pins have reduced drive capability. pupib ? pull-up port ib enable 0 = port ib pull-ups are disabled. 1 = enable pull-up devices for port ib input pins [7:4]. pull-ups for port ib input pins [3:0] are always enabled. ibdr ? iic bus data i/o register $00e4 bit 7654321bit 0 d7 d6 d5 d4 d3 d2 d1 d0 high reset: 0 0000000 ibpurd ? pull-up and reduced drive for port ib $00e5 bit 7654321bit 0 000rdpib000pupib reset: 0 0 000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic register descriptions mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 289 read and write anytime. iic functions scl and sda share port ib pins 7 and 6 and take precedence over the general-purpose port when iic is enabled. the scl and sda output buffers behave as open-drain outputs. when port is configured as input, a read will return the pin level. port bits 3-0 have internal pull ups when configured as inputs so they will read ones. when configured as output, a read will return the latched output data. port bits 5 through 0 will read the last value written. a write will drive associated pins only if configured for output and iic is not enabled. port bits 3-0 do not have available external pins. read and write anytime ddrib[7:4] ? port ib [7:4] data direction each bit determines the primary direction for each pin configured as general-purpose i/o. 0 = associated pin is a high-impedance input. 1 = associated pin is an output. ddrib[3:0] ? these bits serve as memory locations since there are no corresponding external port pins. portib ? port data ib register $00e6 bit 7654321bit 0 pib7 pib6 pib5 pib4 pib3 pib2 pib1 pib0 iicsclsda------ reset: -------- ddrib ? data direction for port ib register $00e7 bit 7654321bit 0 ddrib7 ddrib6 ddrib5 ddrib4 ddrib3 ddrib2 ddrib1 ddrib0 reset: 0 0 0 00000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 290 inter-ic bus motorola 15.7 iic programming examples 15.7.1 initialization sequence reset will put the iic bus control register to its default status. before the interface can be used to transfer serial data, an initialization procedure must be carried out, as follows: 1. update the frequency divider register (ibfd) and select the required division ratio to obtain scl frequency from system clock. 2. update the iic bus address register (ibad) to define its slave address. 3. set the iben bit of the iic bus control register (ibcr) to enable the iic interface system. 4. modify the bits of the iic bus control register (ibcr) to select master/slave mode, transmit/receive mode and interrupt enable or not. 15.7.2 generation of start after completion of the initialization procedure, serial data can be transmitted by selecting the ? master transmitter ? mode. if the device is connected to a multi-master bus system, the state of the iic bus busy bit (ibb) must be tested to check whether the serial bus is free. if the bus is free (ibb=0), the start condition and the first byte (the slave address) can be sent. the data written to the data register comprises the slave calling address and the lsb set to indicate the direction of transfer required from the slave. the bus free time (i.e., the time between a stop condition and the following start condition) is built into the hardware that generates the start cycle. depending on the relative frequencies of the system clock and the scl period it may be necessary to wait until the iic is busy after writing the calling address to the ibdr before proceeding with the following instructions. this is illustrated in the following example. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic programming examples mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 291 an example of a program which generates the start signal and transmits the first byte of data (slave address) is shown below: 15.7.3 post-transfer software response transmission or reception of a byte will set the data transferring bit (tcf) to 1, which indicates one byte communication is finished. the iic bus interrupt bit (ibif) is set also; an interrupt will be generated if the interrupt function is enabled during initialization by setting the ibie bit. software must clear the ibif bit in the interrupt routine first. the tcf bit will be cleared by reading from the iic bus data i/o register (ibdr) in receive mode or writing to ibdr in transmit mode. software may service the iic i/o in the main program by monitoring the ibif bit if the interrupt function is disabled. note that polling should monitor the ibif bit rather than the tcf bit since their operation is different when arbitration is lost. note that when an interrupt occurs at the end of the address cycle the master will always be in transmit mode, i.e. the address is transmitted. if master receive mode is required, indicated by r/w bit in ibdr, then the tx/rx bit should be toggled at this stage. during slave mode address cycles (iaas=1) the srw bit in the status register is read to determine the direction of the subsequent transfer and the tx/rx bit is programmed accordingly. for slave mode data cycles (iaas=0) the srw bit is not valid, the tx/rx bit in the control register should be read to determine the direction of the current transfer. chflag brset ibsr,#$20,* ;wait for ibb flag to clear txstart bset ibcr,#$30 ;set transmit and master mode ;i.e. generate start condition movb calling,ibdr ;transmit the calling ;address, d0=r/w ibfree brclr ibsr,#$20,* ;wait for ibb flag to set f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 292 inter-ic bus motorola the following is an example of a software response by a ? master transmitter ? in the interrupt routine (see figure 15-4 ). 15.7.4 generation of stop a data transfer ends with a stop signal generated by the ? master ? device. a master transmitter can simply generate a stop signal after all the data has been transmitted. the following is an example showing how a stop condition is generated by a master transmitter. if a master receiver wants to terminate a data transfer, it must inform the slave transmitter by not acknowledging the last byte of data which can be done by setting the transmit acknowledge bit (txak) before reading the 2nd last byte of data. before reading the last byte of data, a stop signal must be generated first. the following is an example showing how a stop signal is generated by a master receiver. isr bclr ibsr,#$02 ;clear the ibif flag brclr ibcr,#$20,slave ;branch if in slave mode brclr ibcr,#$10,receive ;branch if in receive mode brset ibsr,#$01,end ;if no ack, end of transmission transmit movb databuf,ibdr ;transmit next byte of data mastx tst txcnt ;get value from the ;transmiting counter beq end ;end if no more data brset ibsr,#$01,end ;end if no ack movb databuf,ibdr ;transmit next byte of data dec txcnt ;decrease the txcnt bra emastx ;exit end bclr ibcr,#$20 ;generate a stop condition emastx rti ;return from interrupt masr dec rxcnt ;decrease the rxcnt beq enmasr ;last byte to be read movb rxcnt,d1 ;check second last byte dec d1 ;to be read bne nxmar ;not last or second last lamar bset ibcr,#$08 ;second last, disable ack ;transmitting bra nxmar enmasr bclr ibcr,#$20 ;last one, generate ?stop? signal f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus iic programming examples mc68hc912dg128 ? rev 3.0 technical data motorola inter-ic bus 293 15.7.5 generation of repeated start at the end of data transfer, if the master still wants to communicate on the bus, it can generate another start signal followed by another slave address without first generating a stop signal. a program example is as shown. 15.7.6 slave mode in the slave interrupt service routine, the module addressed as slave bit (iaas) should be tested to check if a calling of its own address has just been received (see figure 15-4 ). if iaas is set, software should set the transmit/receive mode select bit (tx/rx bit of ibcr) according to the r/w command bit (srw). writing to the ibcr clears the iaas automatically. note that the only time iaas is read as set is from the interrupt at the end of the address cycle where an address match occurred, interrupts resulting from subsequent data transfers will have iaas cleared. a data transfer may now be initiated by writing information to ibdr, for slave transmits, or dummy reading from ibdr, in slave receive mode. the slave will drive scl low in-between byte transfers, scl is released when the ibdr is accessed in the required mode. in the slave transmitter routine, the received acknowledge bit (rxak) must be tested before transmitting the next byte of data. setting rxak means an ? end of data ? signal from the master receiver, after which it must be switched from transmitter mode to receiver mode by software. a dummy read then releases the scl line so that the master can generate a stop signal. nxmar movb ibdr,rxbuf ;read data and store rti masr dec rxcnt ;decrease the rxcnt restart bset ibcr,#$04 another start (restart) movb calling,ibdr ;transmit the calling address ;d0=r/w f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 294 inter-ic bus motorola 15.7.7 arbitration lost if several masters try to engage the bus simultaneously, only one master wins and the others lose arbitration. the devices which lost arbitration are immediately switched to slave receive mode by the hardware. their data output to the sda line is stopped, but scl is still generated until the end of the byte during which arbitration was lost. an interrupt occurs at the falling edge of the ninth clock of this transfer with ibal=1 and ms/sl =0. if one master attempts to start transmission while the bus is being engaged by another master, the hardware will inhibit the transmission; switch the ms/sl bit from 1 to 0 without generating stop condition; generate an interrupt to cpu and set the ibal to indicate that the attempt to engage the bus is failed. when considering these cases, the slave service routine should test the ibal first and the software should clear the ibal bit if it is set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 295 inter-ic bus motorola figure 15-4. flow-chart of typical iic interrupt routine clear master mode ? tx/rx ? last byte transmitted ? rxak=0 ? end of addr cycle (master rx) ? write next byte to ibdr switch to rx mode dummy read from ibdr generate stop signal read data from ibdr and store set txak =1 generate stop signal 2nd last byte to be read ? last byte to be read ? arbitration lost ? clear ibal iaas=1 ? iaas=1 ? srw=1 ? tx/rx ? set tx mode write data to ibdr set rx mode dummy read from ibdr ack from receiver ? tx next byte read data from ibdr and store switch to rx mode dummy read from ibdr rti yn y y y y y y y y y n n n n n n n n n y tx rx rx tx (write) (read) n ibif address transfer data transfer f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
inter-ic bus technical data mc68hc912dg128 ? rev 3.0 296 inter-ic bus motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 297 technical data ? mc68hc912dg128 section 16. analog-to-digital converter 16.1 contents 16.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 16.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 16.4 atd registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 16.5 atd mode operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 16.2 introduction the mc68hc912dg128 has two identical atd modules identified as atd0 and atd1. except for the v dda and v ssa analog supply voltage, all pins are duplicated and indexed with ? 0 ? or ? 1 ? in the following description. an ? x ? indicates either ? 0 ? or ? 1 ? . the atd module is an 8-channel, 10-bit or 8-bit, multiplexed-input successive-approximation analog-to-digital converter. it does not require external sample and hold circuits because of the type of charge redistribution technique used. the atd converter timing can be synchronized to the system p clock. the atd module consists of a 16- word (32-byte) memory-mapped control register block used for control, testing and configuration. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 298 analog-to-digital converter motorola figure 16-1. analog-to-digital converter block diagram 16.3 functional description a single conversion sequence consists of four or eight conversions, depending on the state of the select 8 channel mode (s8cm) bit when atdxctl5 is written. there are eight basic conversion modes. in the non-scan modes, the scf bit is set after the sequence of four or eight conversions has been performed and the atd module halts. in the scan modes, the scf bit is set after the first sequence of four or eight conversions has been performed, and the atd module continues to restart the sequence. in both modes, the ccf bit associated with each register is set when that register is loaded with the appropriate conversion result. that flag is cleared automatically when that result register is read. the conversions are started by writing to the control registers. mode and timing controls atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 sar rc dac array and comparator internal bus v dda v ssa v rlx v rhx clock select/prescale analog mux and sample buffer amp port ad data input register anx7/padx7 anx6/padx6 anx5/padx5 anx4/padx4 anx3/padx3 anx2/padx2 anx1/padx1 anx0/padx0 reference supply f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 299 16.4 atd registers control and data registers for the atd modules are described below. both atds have identical control registers mapped in two blocks of 16 bytes. writes to this register will abort current conversion sequence. read: any time write: any time. write: write to this register has no meaning. read: special mode only. bit 7654321bit 0 reset:00000000 atd0ctl0/atd1ctl0 ? reserved $0060/$01e0 bit 7654321bit 0 reset: 0 0 000000 atd0ctl1/atd1ctl1 ? reserved $0061/$01e1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 300 analog-to-digital converter motorola the atd control register 2 and 3 are used to select the power up mode, interrupt control, and freeze control. writes to these registers abort any current conversion sequence. read or write anytime except ascif bit, which cannot be written. bit positions atdctl2[4:2] and atdctl3[7:2] are unused and always read as zeros. adpu ? atd disable 0 = disables the atd, including the analog section for reduction in power consumption. 1 = allows the atd to function normally. software can disable the clock signal to the a/d converter and power down the analog circuits to reduce power consumption. when reset to zero, the adpu bit aborts any conversion sequence in progress. because the bias currents to the analog circuits are turned off, the atd requires a period of recovery time to stabilize the analog circuits after setting the adpu bit. affc ? atd fast flag clear all 0 = atd flag clearing operates normally (read the status register before reading the result register to clear the associated ccf bit). 1 = changes all atd conversion complete flags to a fast clear sequence. any access to a result register (atd0 ? 7) will cause the associated ccf flag to clear automatically if it was set at the time. awai ? atd wait mode 0 = atd continues to run when the mcu is in wait mode 1 = atd stops to save power when the mcu is in wait mode bit 7654321bit 0 adpu affc awai 0 0 0 ascie ascif reset: 0 0 0 0 0 0 0 0 atd0ctl2/atd1ctl2 ? atd control register 2 $0062/$01e2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 301 when the awai bit is set and the module enters wait mode, most of the clocks stop and the analog portion powers down. when the module comes out of wait, it is recommended that a stabilisation delay (stop and atd power up recovery time, t sr ) is allowed before new conversions are started. additionally, the atd does not re-initialise automatically on leaving wait mode. ascie ? atd sequence complete interrupt enable 0 = disables atd interrupt 1 = enables atd interrupt on sequence complete ascif ? atd sequence complete interrupt flag cannot be written in any mode. 0 = no atd interrupt occurred 1 = atd sequence complete frz1, frz0 ? background debug (freeze) enable (suspend module operation at breakpoint) when debugging an application, it is useful in many cases to have the atd pause when a breakpoint is encountered. these two bits determine how the atd will respond when background debug mode becomes active. bit 7654321bit 0 000000frz1frz0 reset: 0 0 0 0 0 0 0 0 atd0ctl3/atd1ctl3 ? atd control register 3 $0063/$01e3 table 16-1. atd response to background debug enable frz1 frz0 atd response 0 0 continue conversions in active background mode 01 reserved 1 0 finish current conversion, then freeze 1 1 freeze when bdm is active f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 302 analog-to-digital converter motorola the atd control register 4 is used to select the clock source and set up the prescaler. writes to the atd control registers initiate a new conversion sequence. if a write occurs while a conversion is in progress, the conversion is aborted and atd activity halts until a write to atdxctl5 occurs. res10 ? 10 bit mode 0 = 8 bit operation 1 = 10 bit operation smp1, smp0 ? select sample time used to select one of four sample times after the buffered sample and transfer has occurred. bit 7654321bit 0 res10 smp1 smp0 prs4 prs3 prs2 prs1 prs0 reset: 0 0 0 0 0 0 0 1 atd0ctl4/atd1ctl4 ? atd control register 4 $0064/$01e4 table 16-2. final sample time selection smp1 smp0 final sample time 0 0 2 a/d clock periods 0 1 4 a/d clock periods 1 0 8 a/d clock periods 1 1 16 a/d clock periods f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 303 prs4, prs3, prs2, prs1, prs0 ? select divide-by factor for atd p-clock prescaler. the binary value written to these bits (1 to 31) selects the divide-by factor for the modulo counter-based prescaler. the p clock is divided by this value plus one and then fed into a ????? ?????????? ?????????? ??????? ??????? ??? ????????????? ?????????? ? ? ?????????? ? ???? ? ? ?? ????????????? ?????????? ?? ????????????? ??????? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 304 analog-to-digital converter motorola the atd control register 5 is used to select the conversion modes, the conversion channel(s), and initiate conversions. read or write any time. writes to the atd control registers initiate a new conversion sequence. if a conversion sequence is in progress when a write occurs, that sequence is aborted and the scf and ccf bits are reset. s8cm ? select 8 channel mode 0 = conversion sequence consists of four conversions 1 = conversion sequence consists of eight conversions scan ? enable continuous channel scan 0 = single conversion sequence 1 = continuous conversion sequences (scan mode) when a conversion sequence is initiated by a write to the atdxctl register, the user has a choice of performing a sequence of four (or eight, depending on the s8cm bit) conversions or continuously performing four (or eight) conversion sequences. mult ? enable multichannel conversion 0 = atd sequencer runs all four or eight conversions on a single input channel selected via the cd, cc, cb, and ca bits. 1 = atd sequencer runs each of the four or eight conversions on sequential channels in a specific group. refer to table 16-4 . bit 7654321bit 0 0 s8cm scan mult cd cc cb ca reset: 0 0 000000 atd0ctl5/atd1ctl5 ? atd control register 5 $0065/$01e5 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 305 cd, cc, cb, and ca ? channel select for conversion table 16-4. multichannel mode result register assignment s8cm cd cc cb ca channel signal result in adrxx if mult = 1 000 0 0 an0 adrx0 0 1 an1 adrx1 1 0 an2 adrx2 1 1 an3 adrx3 001 0 0 an4 adrx0 0 1 an5 adrx1 1 0 an6 adrx2 1 1 an7 adrx3 010 0 0 reserved adrx0 0 1 reserved adrx1 1 0 reserved adrx2 1 1 reserved adrx3 011 0 0 v rh adrx0 0 1 v rl adrx1 1 0 (v rh + v rl )/2 adrx2 1 1 test/reserved adrx3 10 0 0 0 an0 adrx0 0 0 1 an1 adrx1 0 1 0 an2 adrx2 0 1 1 an3 adrx3 1 0 0 an4 adrx4 1 0 1 an5 adrx5 1 1 0 an6 adrx6 1 1 1 an7 adrx7 11 0 0 0 reserved adrx0 0 0 1 reserved adrx1 0 1 0 reserved adrx2 0 1 1 reserved adrx3 1 0 0 v rh adrx4 1 0 1 v rl adrx5 1 1 0 (v rh + v rl )/2 adrx6 1 1 1 test/reserved adrx7 shaded bits are ? don ? t care ? if mult = 1 and the entire block of four or eight channels make up a conversion sequence. when mult = 0, all four bits (cd, cc, cb, and ca) must be specified and a conversion sequence consists of four or eight consecutive conversions of the single specified channel. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 306 analog-to-digital converter motorola note: conversion of (vrh-vrl)/2 returns $7f, $80 or $81 in 8-bit mode. the atd status registers contain the flags indicating the completion of atd conversions. normally, it is read-only. in special mode, the scf bit and the ccf bits may also be written. scf ? sequence complete flag this bit is set at the end of the conversion sequence when in the single conversion sequence mode (scan = 0 in atdxctl5) and is set at the end of the first conversion sequence when in the continuous conversion mode (scan = 1 in atdxctl5). when affc = 0, scf is cleared when a write is performed to atdxctl5 to initiate a new conversion sequence. when affc = 1, scf is cleared after the first result register is read. cc[2:0] ? conversion counter for current sequence of four or eight conversions this 3-bit value reflects the contents of the conversion counter pointer in a four or eight count sequence. this value also reflects which result register will be written next, indicating which channel is currently being converted. ccf[7:0] ? conversion complete flags bit 7654321bit 0 scf 0 0 0 0 cc2 cc1 cc0 reset:00000000 atd0stat0/atd1stat0 ? atd status register $0066/$01e6 atd0stat1/atd1stat1 ? atd status register $0067/$01e7 bit 7654321bit 0 ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 reset: 0 0000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 307 each of these bits are associated with an individual atd result register. for each register, this bit is set at the end of conversion for the associated atd channel and remains set until that atd result register is read. it is cleared at that time if affc bit is set, regardless of whether a status register read has been performed (i.e., a status register read is not a pre-qualifier for the clearing mechanism when affc = 1). otherwise the status register must be read to clear the flag. the test registers control various special modes which are used during manufacturing. the test register can be read or written only in the special modes. in the normal modes, reads of the test register return zero and writes have no effect. sar[9:0] ? sar data reads of this byte return the current value in the sar. writes to this byte change the sar to the value written. bits sar[9:0] reflect the ten sar bits used during the resolution process for a 10-bit result. bit 7654321bit 0 sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 reset: 0 0 000000 atd0testh/atd1testh ? atd test register $0068/$01e8 bit 7654321bit 0 sar1 sar0 rst tstout tst3 tst2 tst1 tst0 reset: 0 0 0 0 0 0 0 0 atd0testl/atd1testl ? atd test register $0069/$01e9 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 308 analog-to-digital converter motorola rst ? module reset bit when set, this bit causes all registers and activity in the module to assume the same state as out of power-on reset (except for adpu bit in atdctl2, which remains set, allowing the atd module to remain enabled). tstout ? multiplex output of tst[3:0] (factory use) tst[3:0] ? test bits 3 to 0 (reserved) selects one of 16 reserved factory testing modes padx[7:0] ? port ad data input bits after reset these bits reflect the state of the input pins. may be used for general-purpose digital input. when the software reads portadx, it obtains the digital levels that appear on the corresponding port ad pins. pins with signals not meeting v il or v ih specifications will have an indeterminate value. writes to this register have no meaning at any time. bit 7654321bit 0 padx7 padx6 padx5 padx4 padx3 padx2 padx1 padx0 reset: - - - - - - - - portad0/portad1 ? port ad data input register $006f/$01ef f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter atd registers mc68hc912dg128 ? rev 3.0 technical data motorola analog-to-digital converter 309 adrxxh[7:0] ? atd conversion result (high) the reset condition for these registers is undefined. in 8-bit mode, these registers contain the left-justified, unsigned result from the 8-bit atd conversion. in 10-bit mode these registers contain the high order bits of the conversion result. adrxxl[7:0] ? atd conversion result (low) the reset condition for these registers is undefined. in 8-bit mode, these registers bits are reserved. in 10-bit mode these registers contain the remaining two low order bits of the conversion result in bits 6 and 7. 8-bit mode bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 10-bit mode bit 9bit 8bit 7bit 6bit 5bit 4bit 3bit 2 reset: uuuuuuuu adrx0h ? a/d conversion result register high 0 $0070/$01f0 adrx1h ? a/d conversion result register high 1 $0072/$01f2 adrx2h ? a/d conversion result register high 2 $0074/$01f4 adrx3h ? a/d conversion result register high 3 $0076/$01f6 adrx4h ? a/d conversion result register high 4 $0078/$01f8 adrx5h ? a/d conversion result register high 5 $007a/$01fa adrx6h ? a/d conversion result register high 6 $007c/$01fc adrx7h ? a/d conversion result register high 7 $007e/$01fe 8-bit mode ???????? 10-bit mode bit 1 bit 0 ?????? reset: uuuuuuuu adrx0l ? a/d conversion result register low 0 $0071/$01f1 adrx1l ? a/d conversion result register low 1 $0073/$01f3 adrx2l ? a/d conversion result register low 2 $0075/$01f5 adrx3l ? a/d conversion result register low 3 $0077/$01f7 adrx4l ? a/d conversion result register low 4 $0079/$01f9 adrx5l ? a/d conversion result register low 5 $007b/$01fb adrx6l ? a/d conversion result register low 6 $007d/$01fd adrx7l ? a/d conversion result register low 7 $007f/$01ff f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
analog-to-digital converter technical data mc68hc912dg128 ? rev 3.0 310 analog-to-digital converter motorola the channel from which this result was obtained is dependent on the conversion mode selected. the registers are always read-only in normal mode. 16.5 atd mode operation stop ? causes all clocks to halt (if the s bit in the ccr is zero). the system is placed in a minimum-power standby mode. this aborts any conversion sequence in progress. wait ? atd conversion continues unless awai bit in atdxctl2 register is set. bdm ? debug options available as set in register atdxctl3. user ? atd continues running unless adpu is cleared. adpu ? atd operations are stopped if adpu = 0, but registers are accessible. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 311 technical data ? mc68hc912dg128 section 17. mscan controller 17.1 contents 17.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 17.3 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 17.4 message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313 17.5 identifier acceptance filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 17.6 interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 17.7 protocol violation protection. . . . . . . . . . . . . . . . . . . . . . . . . . 324 17.8 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 17.9 timer link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 17.10 clock system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 17.11 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 17.12 programmer ? s model of message storage . . . . . . . . . . . . . . .332 17.13 programmer ? s model of control registers . . . . . . . . . . . . . . . 338 17.2 introduction the mc68hc912dg128 has two identical mscan12 modules, identified as can0 and can1. the information to follow describes one mscan unless specifically noted and register locations specifically relate to can0. can1 registers are located 512 bytes from can0. the mscan12 is the specific implementation of the motorola scalable can (mscan) concept targeted for the motorola m68hc12 microcontroller family. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 312 mscan controller motorola the module is a communication controller implementing the can 2.0 a/b protocol as defined in the bosch specification dated september 1991. the can protocol was primarily, but not only, designed to be used as a vehicle serial data bus, meeting the specific requirements of this field: real-time processing, reliable operation in the emi environment of a vehicle, cost-effectiveness and required bandwidth. mscan12 utilizes an advanced buffer arrangement resulting in a predictable real-time behavior and simplifies the application software. 17.3 external pins the mscan12 uses 2 external pins, 1 input (rxcan) and 1 output (txcan). the txcan output pin represents the logic level on the can: 0 is for a dominant state, and 1 is for a recessive state. rxcan is on bit 0 of port can, txcan is on bit 1. the remaining six pins of port can are controlled by registers in the mscan12 address space (see mscan12 port can control register (pctlcan) and mscan12 port can data direction register (ddrcan) ). a typical can system with mscan12 is shown in figure 17-1 . each can station is connected physically to the can bus lines through a transceiver chip. the transceiver is capable of driving the large current needed for the can and has current protection, against defective can or defective stations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 313 figure 17-1. the can system 17.4 message storage mscan12 facilitates a sophisticated message storage system which addresses the requirements of a broad range of network applications. 17.4.1 background modern application layer software is built upon two fundamental assumptions: 1. any can node is able to send out a stream of scheduled messages without releasing the bus between two messages. such nodes will arbitrate for the bus right after sending the previous message and will only release the bus arbitration is lost. 2. the internal message queue within any can node is organized such that if more than one message is ready to be sent, the highest priority message will be sent out first. transceiver mscan12 can system can station 1 can station 2 can station n can txcan rxcan ..... controller f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 314 mscan controller motorola the bove behavior cannot be achieved with a single transmit buffer. that buffer must be reloaded right after the previous message has been sent. this loading process lasts a definite amount of time and has to be completed within the inter-frame sequence (ifs) in order to be able to send an uninterrupted stream of messages. even if this is feasible for limited can bus speeds it requires that the cpu reacts with short latencies to the transmit interrupt. a double buffer scheme would de-couple the re-loading of the transmit buffers from the actual message sending and as such reduces the reactiveness requirements on the cpu. problems may arise if the sending of a message would be finished just while the cpu re-loads the second buffer, no buffer would then be ready for transmission and the bus would be released. at least three transmit buffers are required to meet the first of above requirements under all circumstances. the mscan12 has three transmit buffers. the second requirement calls for some sort of internal prioritization which the mscan12 implements with the local priority concept described below. 17.4.2 receive structures the received messages are stored in a two stage input fifo. the two message buffers are alternately mapped into a single memory area (see figure 17-2 ). while the background receive buffer (rxbg) is exclusively associated to the mscan12, the foreground receive buffer (rxfg) is addressable by the cpu12. this scheme simplifies the handler software as only one address area is applicable for the receive process. both buffers have a size of 13 bytes to store the can control bits, the identifier (standard or extended) and the data contents (for details see programmer ? s model of message storage ). the receiver full flag (rxf) in the mscan12 receiver flag register (crflg) (see mscan12 receiver flag register (crflg) ) signals the status of the foreground receive buffer. when the buffer contains a correctly received message with matching identifier this flag is set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 315 on reception, each message is checked to see if it passes the filter (for details see identifier acceptance filter ) and in parallel is written into rxbg. the mscan12 copies the content of rxbg into rxfg (1) , sets the rxf flag, and generates a receive interrupt to the cpu (2) . the user ? s receive handler has to read the received message from rxfg and then reset the rxf flag in order to acknowledge the interrupt and to release the foreground buffer. a new message, which can follow immediately after the ifs field of the can frame, is received into rxbg. the over-writing of the background buffer is independent of the identifier filter function. 1. only if the rxf flag is not set. 2. the receive interrupt is generated only if not masked. a polling scheme can be applied on rxf also. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 316 mscan controller motorola figure 17-2. user model for message buffer organization when the mscan12 module is transmitting, the mscan12 receives its own messages into the background receive buffer, rxbg, but does not overwrite rxfg, generate a receive interrupt or acknowledge its own messages on the can bus. the exception to this rule is in loop-back mode (see mscan12 module control register 0 (cmcr0) ) where the mscan12 treats its own messages exactly like all other incoming messages. the mscan12 receives its own transmitted messages in the event that it loses arbitration. if arbitration is lost, the mscan12 must be prepared to become receiver. rxfg rxbg tx0 rxf txe prio tx1 txe prio tx2 txe prio mscan12 cpu bus f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 317 an overrun condition occurs when both the foreground and the background receive message buffers are filled with correctly received messages with accepted identifiers and another message is correctly received from the bus with an accepted identifier. the latter message is discarded and an error interrupt with overrun indication is generated if enabled. the mscan12 is still able to transmit messages with both receive message buffers filled, but all incoming messages are discarded. note: the mscan12 will receive its own messages into the background receive buffer rxbg but will not overwrite rxfg and will not emit a receive interrupt nor will it acknowledge (ack) its own messages on the can bus. the exception to this rule is that when in loop-back mode mscan12 will treat its own messages exactly like all other incoming messages. 17.4.3 transmit structures the mscan12 has a triple transmit buffer scheme in order to allow multiple messages to be set up in advance and to achieve an optimized real-time performance. the three buffers are arranged as shown in figure 17-2 . all three buffers have a 13 byte data structure similar to the outline of the receive buffers (see programmer ? s model of message storage ). an additional transmit buffer priority register (tbpr) contains an 8-bit so called local priority field (prio) (see transmit buffer priority registers (tbpr) ). in order to transmit a message, the cpu12 has to identify an available transmit buffer which is indicated by a set transmit buffer empty (txe) flag in the mscan12 transmitter flag register (ctflg) (see mscan12 transmitter flag register (ctflg) ). the cpu12 then stores the identifier, the control bits and the data content into one of the transmit buffers. finally, the buffer has to be flagged as being ready for transmission by clearing the txe flag. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 318 mscan controller motorola the mscan12 will then schedule the message for transmission and will signal the successful transmission of the buffer by setting the txe flag. a transmit interrupt will be emitted (1) when txe is set and this can be used to drive the application software to re-load the buffer. if more than one buffer is scheduled for transmission when the can bus becomes available for arbitration, the mscan12 uses the local priority setting of the three buffers for prioritisation. for this purpose every transmit buffer has an 8-bit local priority field (prio). the application software sets this field when the message is set up. the local priority reflects the priority of this particular message relative to the set of messages being emitted from this node. the lowest binary value of the prio field is defined to be the highest priority. the internal scheduling process takes places whenever the mscan12 arbitrates for the bus. this is also the case after the occurrence of a transmission error. when a high priority message is scheduled by the application software it may become necessary to abort a lower priority message being set up in one of the three transmit buffers. as messages that are already under transmission cannot be aborted, the user has to request the abort by setting the corresponding abort request flag (abtrq) in the transmission control register (ctcr). the mscan12 grants the request, if possible, by setting the corresponding abort request acknowledge (abtak) and the txe flag in order to release the buffer and by generating a transmit interrupt. the transmit interrupt handler software can tell from the setting of the abtak flag whether the message was aborted (abtak=1) or sent in the meantime (abtak=0). 17.5 identifier acceptance filter the identifier acceptance registers (cidar0 ? 7) define the acceptable patterns of the standard or extended identifier (id10 ? id0 or id28 ? id0). any of these bits can be marked don ? t care in the identifier mask registers (cidmr0 ? 7). 1. the transmit interrupt will occur only if not masked. a polling scheme can be applied on txe also. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller identifier acceptance filter mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 319 a filter hit is indicated to the application software by a set rxf (receive buffer full flag, see mscan12 receiver flag register (crflg) ) and three bits in the identifier acceptance control register (see mscan12 identifier acceptance control register (cidac) ). these identifier hit flags (idhit2 ? 0) clearly identify the filter section that caused the acceptance. they simplify the application software ? s task to identify the cause of the receiver interrupt. when more than one hit occurs (two or more filters match) the lower hit has priority. a very flexible programmable generic identifier acceptance filter has been introduced in order to reduce the cpu interrupt loading. the filter is programmable to operate in four different modes:  two identifier acceptance filters, each to be applied to: a) the full 29 bits of the extended identifier and to the following bits of the can frame: rtr, ide, srr or b) the 11 bits of the standard identifier, the rtr and ide bits of can 2.0a/b messages. this mode implements two filters for a full length can 2.0b compliant extended identifier. figure 17-3 shows how the first 32- bit filter bank (cidar0 ? 3, cidmr0 ? 3) produces a filter 0 hit. similarly, the second filter bank (cidar4 ? 7, cidmr4 ? 7) produces a filter 1 hit.  four identifier acceptance filters, each to be applied to: a) the 14 most significant bits of the extended identifier plus the srr and ide bits of can 2.0b messages or b) the 11 bits of the standard identifier, the rtr and ide bits of can 2.0a/b messages. figure 17-4 shows how the first 32-bit filter bank (cidar0 ? 3, cidmr0 ? 3) produces filter 0 and 1 hits. similarly, the second filter bank (cidar4 ? 7, cidmr4 ? 7) produces filter 2 and 3 hits.  eight identifier acceptance filters, each to be applied to the first 8 bits of the identifier. this mode implements eight independent filters for the first 8 bits of a can 2.0a/b compliant standard identifier or of a can 2.0b compliant extended identifier. figure 17-5 shows how the first 32-bit filter bank (cidar0 ? 3, cidmr0 ? 3) produces filter 0 to 3 hits. similarly, the second filter bank (cidar4 ? 7, cidmr4 ? 7) produces filter 4 to 7 hits. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 320 mscan controller motorola  closed filter. no can message will be copied into the foreground buffer rxfg, and the rxf flag will never be set. figure 17-3. 32-bit maskable identifier acceptance filters figure 17-4. 16-bit maskable acceptance filters cidmr2 id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide am7 idr0 idr0 idr1 idr1 idr2 idr3 am0 am7 am0 am7 am7 am0 am0 ac7 ac0 ac7 ac0 ac7 ac0 ac7 ac0 cidmro cidmr1 cidmr3 cidar3 cidar2 cidar1 cidaro id accepted (filter 0 hit) id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide am7 idr0 idr0 idr1 idr1 idr2 idr3 am0 am7 am0 ac7 ac0 ac7 ac0 cidmro cidmr1 cidar1 cidaro id accepted (filter 0 hit) id accepted (filter 1 hit) am7 am0 am7 am0 ac7 ac0 ac7 ac0 cidmr2 cidmr3 cidar3 cidar2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller identifier acceptance filter mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 321 figure 17-5. 8-bit maskable acceptance filters the identifier acceptance registers (cidar0 ? 7) define the acceptable patterns of the standard or extended identifier (id10 ? id0 or id28 ? id0). any of these bits can be marked don ? t care in the identifier mask registers (cidmr0 ? 7). a filter hit is indicated to the application software by a set rxf (receive buffer full flag, see mscan12 receiver flag register (crflg) ) and id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide am7 idr0 idr0 idr1 idr1 idr2 idr3 am0 ac7 ac0 cidmro cidaro id accepted (filter 0 hit) am7 am0 ac7 ac0 cidmr1 cidar1 am7 am0 ac7 ac0 cidmr2 cidar2 id accepted (filter 1 hit) id accepted (filter 2 hit) am7 am0 ac7 ac0 cidmr3 cidar3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 322 mscan controller motorola three bits in the identifier acceptance control register (see mscan12 identifier acceptance control register (cidac) ). these identifier hit flags (idhit2 ? 0) clearly identify the filter section that caused the acceptance. they simplify the application software ? s task to identify the cause of the receiver interrupt. in case that more than one hit occurs (two or more filters match) the lower hit has priority. a hit will also cause a receiver interrupt if enabled. 17.6 interrupts the mscan12 supports four interrupt vectors mapped onto eleven different interrupt sources, any of which can be individually masked (for details see mscan12 receiver flag register (crflg) to mscan12 transmitter control register (ctcr) ):  transmit interrupt : at least one of the three transmit buffers is empty (not scheduled) and can be loaded to schedule a message for transmission. the txe flags of the empty message buffers are set.  receive interrupt : a message has been successfully received and loaded into the foreground receive buffer. this interrupt is generated immediately after receiving the eof symbol. the rxf flag is set.  wake-up interrupt : an activity on the can bus occurred during mscan12 internal sleep mode.  error interrupt : an overrun, error or warning condition occurred. the receiver flag register (crflg) indicates one of the following conditions: ? overrun: an overrun condition as described in receive structures has occurred. ? receiver warning : the receive error counter has reached the cpu warning limit of 96. ? transmitter warning : the transmit error counter has reached the cpu warning limit of 96. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller interrupts mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 323 ? receiver error passive : the receive error counter has exceeded the error passive limit of 127 and mscan12 has gone to error passive state. ? transmitter error passive : the transmit error counter has exceeded the error passive limit of 127 and mscan12 has gone to error passive state. ? bus off : the transmit error counter has exceeded 255 and mscan12 has gone to busoff state. 17.6.1 interrupt acknowledge interrupts are directly associated with one or more status flags in either the mscan12 receiver flag register (crflg) or the mscan12 transmitter flag register (ctflg). interrupts are pending as long as one of the corresponding flags is set. the flags in above registers must be reset within the interrupt handler in order to handshake the interrupt. the flags are reset through writing a 1 to the corresponding bit position. a flag cannot be cleared if the respective condition still prevails. note: bit manipulation instructions (bset) shall not be used to clear interrupt flags. 17.6.2 interrupt vectors the mscan12 supports four interrupt vectors as shown in table 17-1 . the vector addresses and the relative interrupt priority are dependent on the chip integration and to be defined. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 324 mscan controller motorola 17.7 protocol violation protection the mscan12 will protect the user from accidentally violating the can protocol through programming errors. the protection logic implements the following features:  the receive and transmit error counters cannot be written or otherwise manipulated.  all registers which control the configuration of the mscan12 cannot be modified while the mscan12 is on-line. the sftres bit in cmcr0 (see mscan12 module control register 0 (cmcr0) ) serves as a lock to protect the following registers: ? mscan12 module control register 1 (cmcr1) ? mscan12 bus timing register 0 and 1 (cbtr0, cbtr1) ? mscan12 identifier acceptance control register (cidac) ? mscan12 identifier acceptance registers (cidar0 ? 7) ? mscan12 identifier mask registers (cidmr0 ? 7)  the txcan pin is forced to recessive when the mscan12 is in any of the low power modes. table 17-1. mscan12 interrupt vectors function source local mask global mask wake-up wupif wupie i bit error interrupts rwrnif rwrnie twrnif twrnie rerrif rerrie terrif terrie boffif boffie ovrif ovrie receive rxf rxfie transmit txe0 txeie0 txe1 txeie1 txe2 txeie2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller low power modes mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 325 17.8 low power modes in addition to normal mode, the mscan12 has three modes with reduced power consumption: sleep, soft_reset and power_down. in sleep and soft_reset modes, power consumption is reduced by stopping all clocks except those to access the registers. in power_down mode, all clocks are stopped and no power is consumed. the wai and stop instructions put the mcu in low power consumption stand-by modes. table 17-2 summarizes the combinations of mscan12 and cpu modes. a particular combination of modes is entered for the given settings of the bits cswai, slpak, and sftres. for all modes, an mscan wake-up interrupt can occur only if slpak=wupie=1. while the cpu is in wait mode, the mscan12 can be operated in normal mode and generate interrupts (registers can be accessed via background debug mode). table 17-2. mscan12 vs. cpu operating modes mscan mode cpu mode stop wait run power_down cswai = x (1) slpak = x sftres = x 1. x means don ? t care. cswai = 1 slpak = x sftres = x sleep cswai = 0 slpak = 1 sftres = 0 cswai = x slpak = 1 sftres = 0 soft_reset cswai = 0 slpak = 0 sftres = 1 cswai = x slpak = 0 sftres = 1 normal cswai = 0 slpak = 0 sftres = 0 cswai = x slpak = 0 sftres = 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 326 mscan controller motorola 17.8.1 mscan12 sleep mode the cpu can request the mscan12 to enter this low-power mode by asserting the slprq bit in the module configuration register (see figure 17-6 ). the time when the mscan12 enters sleep mode depends on its activity:  if one or more message buffers are scheduled for transmission (txex = 0), the mscan will continue to transmit until all transmit message buffers are empty (txex = 1, transmitted successfully or aborted) and then goes into sleep mode  if it is receiving, it continues to receive and goes into sleep mode as soon as the can bus next becomes idle  if it is neither transmitting nor receiving, it will immediately go into sleep mode note: the application software must avoid setting up a transmission (by clearing one or more txe flag(s)) and immediately request sleep mode (by setting slprq). it then depends on the exact sequence of operations whether the mscan12 starts transmitting or goes into sleep mode directly. during sleep mode, the slpak flag is set. the application software should use slpak as a handshake indication for the request (slprq) to go into sleep mode. when in sleep mode, the mscan12 stops its internal clocks. however, clocks to allow register accesses still run. if the mscan12 is in bus-off state, it stops counting the 128*11 consecutive recessive bits due to the stopped clock. the txcan pin stays in recessive state. if rxf=1, the message can be read and rxf can be cleared. copying of rxbg into rxfg does not take place while in sleep mode. it is possible to access the transmit buffers and to clear the txe flags. no message abort takes place while in sleep mode. the mscan12 leaves sleep mode (wake-up) when  bus activity occurs or  the mcu clears the slprq bit or  the mcu sets sftres. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller low power modes mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 327 note: the mcu cannot clear the slprq bit before the mscan12 is in sleep mode (slpak = 1). after wake-up, the mscan12 waits for 11 consecutive recessive bits to synchronize to the bus. as a consequence, if the mscan12 is woken-up by a can frame, this frame is not received. the receive message buffers (rxbg and rxfg) contain messages if they were received before sleep mode was entered. all pending actions are executed upon wake-up: copying of rxbg into rxfg, message aborts and message transmissions. if the mscan12 is still in bus-off state after leaving sleep mode, it continues counting the 128*11 consecutive recessive bits. figure 17-6. sleep request / acknowledge cycle 17.8.2 mscan12 soft_reset mode in soft_reset mode, the mscan12 is stopped. registers can still be accessed. this mode is used to initialize the module configuration, bit timing, and the can message filter. see mscan12 module control register 0 (cmcr0) for a complete description of the soft_reset mode. mscan12 sleeping slprq = 1 slpak = 1 mscan12 running slprq = 0 slpak = 0 sleep request slprq = 1 slpak = 0 mcu mscan12 mcu or mscan12 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 328 mscan controller motorola note: when setting the sftres bit, the mscan12 immediately stops all ongoing transmissions and receptions, potentially causing the can protocol violations. the user is responsiblefor ensuring that the mscan12 is not active when soft_reset mode is entered. the recommended procedure is to bring the mscan12 into sleep mode before the sftres bit is set. 17.8.3 mscan12 power_down mode the mscan12 is in power_down mode when  the cpu is in stop mode or  the cpu is in wait mode and the cswai bit is set (see mscan12 module control register 0 (cmcr0) ). when entering the power_down mode, the mscan12 immediately stops all ongoing transmissions and receptions, potentially causing can protocol violations. note: the user is responsible to take care that the mscan12 is not active when power_down mode is entered. the recommended procedure is to bring the mscan12 into sleep mode before the stop instruction (or the wai instruction, if cswai is set) is executed. to protect the can bus system from fatal consequences of violations to the above rule, the mscan12 drives the txcan pin into recessive state. in power_down mode, no registers can be accessed. 17.8.4 programmable wake-up function the mscan12 can be programmed to apply a low-pass filter function to the rxcan input line while in sleep mode (see control bit wupm in the module control register, mscan12 module control register 0 (cmcr0) ). this feature can be used to protect the mscan12 from wake-up due to short glitches on the can bus lines. such glitches can result from electromagnetic interference within noisy environments. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller timer link mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 329 17.9 timer link the mscan12 generates a timer signal whenever a valid frame has been received. because the can specification defines a frame to be valid if no errors occurred before the eof field has been transmitted successfully, the timer signal is generated right after the eof. a pulse of one bit time is generated. as the mscan12 receiver engine also receives the frames being sent by itself, a timer signal is also generated after a successful transmission. the previously described timer signal can be routed into the on-chip timer interface module (ect). this signal is connected to the timer n channel input under the control of the timer link enable (tlnken) bit in the cmcr0 (1) . after timer n has been programmed to capture rising edge events, it can be used under software control to generate 16-bit time stamps which can be stored with the received message. 17.10 clock system figure 17-7 shows the structure of the mscan12 clock generation circuitry. with this flexible clocking scheme the mscan12 is able to handle can bus rates ranging from 10 kbps up to 1 mbps. figure 17-7. clocking scheme 1. the timer channel being used for the timer link for can0 is channel 4 and for can1 is channel 5. mscan12 cgm sysclk extali cgmcanclk prescaler (1...64) time quanta clock clksrc clksrc f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 330 mscan controller motorola the clock source bit (clksrc) in the mscan12 module control register (cmcr1) (see mscan12 bus timing register 0 (cbtr0) ) defines whether the mscan12 is connected to the output of the crystal oscillator (extali) or to a clock twice as fast as the system clock (eclk). the clock source has to be chosen such that the tight oscillator tolerance requirements (up to 0.4%) of the can protocol are met. additionally, for high can bus rates (1 mbps), a 50% duty cycle of the clock is required. note: if the system clock is generated from a pll, it is recommended to select the crystal clock source rather than the system clock source due to jitter considerations, especially at faster can bus rates . for microcontrollers without the cgm module, cgmcanclk is driven from the crystal oscillator (extali). a programmable prescaler is used to generate out of mscanclk the time quanta (tq) clock. a time quantum is the atomic unit of time handled by the mscan12. a bit time is subdivided into three segments (1) :  sync_seg: this segment has a fixed length of one time quantum. signal edges are expected to happen within this section.  time segment 1: this segment includes the prop_seg and the phase_seg1 of the can standard. it can be programmed by setting the parameter tseg1 to consist of 4 to 16 time quanta.  time segment 2: this segment represents the phase_seg2 of the can standard. it can be programmed by setting the tseg2 parameter to be 2 to 8 time quanta long. the synchronization jump width can be programmed in a range of 1 to 4 time quanta by setting the sjw parameter. 1. for further explanation of the under-lying concepts please refer to iso/dis 11519-1, section 10.3. f t q f cgmcanclk presc value ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller clock system mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 331 the above parameters can be set by programming the bus timing registers (cbtr0 ? 1, see mscan12 bus timing register 0 (cbtr0) and mscan12 bus timing register 1 (cbtr1) ). note: it is the user ? s responsibility to make sure that his bit time settings are in compliance with the can standard. figure 17-9 gives an overview on the can conforming segment settings and the related parameter values. figure 17-8. segments within the bit time figure 17-9. can standard compliant bit time segment settings time segment 1 tseg1 time segment 2 tseg2 synchron. jump width sjw 5 .. 10 4 .. 9 2 1 1 .. 2 0 .. 1 4 .. 11 3 .. 10 3 2 1 .. 3 0 .. 2 5 .. 12 4 .. 11 4 3 1 .. 4 0 .. 3 6 .. 13 5 .. 12 5 4 1 .. 4 0 .. 3 7 .. 14 6 .. 13 6 5 1 .. 4 0 .. 3 8 .. 15 7 .. 14 7 6 1 .. 4 0 .. 3 9 .. 16 8 .. 15 8 7 1 .. 4 0 .. 3 sync _seg time segment 1 time seg. 2 1 4 ... 16 2 ... 8 8... 25 time quanta = 1 bit time nrz signal sample point (single or triple sampling) (prop_seg + phase_seg1) (phase_seg2) transmit point f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 332 mscan controller motorola 17.11 memory map the mscan12 occupies 128 bytes in the cpu12 memory space. the background receive buffer can only be read in test mode. 17.12 programmer ? s model of message storage the following section details the organisation of the receive and transmit message buffers and the associated control registers. for reasons of programmer interface simplification the receive and transmit message buffers have the same outline. each message buffer allocates 16 bytes in the memory map containing a 13 byte data structure. an additional transmit buffer priority register (tbpr) is defined for the transmit buffers. figure 17-10. mscan12 memory map $0100 control registers 9 bytes $0108 $0109 reserved 5 bytes $010d $010e error counters 2 bytes $010f $0110 identifier filter 16 bytes $011f $0120 reserved 29 bytes $013c $013d port can registers 3 bytes $013f $0140 foreground receive buffer $014f $0150 transmit buffer 0 $015f $0160 transmit buffer 1 $016f $0170 transmit buffer 2 $017f f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 333 17.12.1 message buffer outline figure 17-12 shows the common 13 byte data structure of receive and transmit buffers for extended identifiers. the mapping of standard identifiers into the idr registers is shown in figure 17-13 . all bits of the 13 byte data structure are undefined out of reset. note: the foreground receive buffer can be read anytime but cannot be written. the transmit buffers can be read or written anytime. figure 17-11. message buffer organization address (1) 1. x is 4, 5, 6, or 7 depending on which buffer rxfg, tx0, tx1, or tx2 respectively. register name 01x0 identifier register 0 01x1 identifier register 1 01x2 identifier register 2 01x3 identifier register 3 01x4 data segment register 0 01x5 data segment register 1 01x6 data segment register 2 01x7 data segment register 3 01x8 data segment register 4 01x9 data segment register 5 01xa data segment register 6 01xb data segment register 7 01xc data length register 01xd transmit buffer priority register (2) 2. not applicable for receive buffers 01xe unused 01xf unused f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 334 mscan controller motorola figure 17-12. receive/transmit message buffer extended identifier addr (1) registerr/wbit 7654321bit 0 $01x0 idr0 r id28 id27 id26 id25 id24 id23 id22 id21 w $01x1 idr1 r id20 id19 id18 srr (1) ide (1) id17 id16 id15 w $01x2 idr2 r id14 id13 id12 id11 id10 id9 id8 id7 w $01x3 idr3 r id6 id5 id4 id3 id2 id1 id0 rtr w $01x4 dsr0 r db7 db6 db5 db4 db3 db2 db1 db0 w $01x5 dsr1 r db7 db6 db5 db4 db3 db2 db1 db0 w $01x6 dsr2 r db7 db6 db5 db4 db3 db2 db1 db0 w $01x7 dsr3 r db7 db6 db5 db4 db3 db2 db1 db0 w $01x8 dsr4 r db7 db6 db5 db4 db3 db2 db1 db0 w $01x9 dsr5 r db7 db6 db5 db4 db3 db2 db1 db0 w $01xa dsr6 r db7 db6 db5 db4 db3 db2 db1 db0 w $01xb dsr7 r db7 db6 db5 db4 db3 db2 db1 db0 w $01xc dlr r dlc3 dlc2 dlc1 dlc0 w 1. x is 4, 5, 6, or 7 depending on which buffer rxfg, tx0, tx1, or tx2 respectively. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 335 17.12.2 identifier registers (idrn) the identifiers consist of either 11 bits (id10 ? id0) for the standard, or 29 bits (id28 ? id0) for the extended format. id10/28 is the most significant bit and is transmitted first on the bus during the arbitration procedure. the priority of an identifier is defined to be highest for the smallest binary number. srr ? substitute remote request this fixed recessive bit is used only in extended format. it must be set to 1 by the user for transmission buffers and will be stored as received on the can bus for receive buffers. ide ? id extended this flag indicates whether the extended or standard identifier format is applied in this buffer. in the case of a receive buffer the flag is set as being received and indicates to the cpu how to process the buffer identifier registers. in the case of a transmit buffer the flag indicates to the mscan12 what type of identifier to send. 0 = standard format (11-bit) 1 = extended format (29-bit) figure 17-13. standard identifier mapping addr (1) registerr/wbit 7654321bit 0 $01x0 idr0 r id10 id9 id8 id7 id6 id5 id4 id3 w $01x1 idr1 r id2 id1 id0 rtr ide(0) w $01x2 idr2 r w $01x3 idr3 r w 1. x is 4, 5, 6, or 7 depending on which buffer rxfg, tx0, tx1, or tx2 respectively. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 336 mscan controller motorola rtr ? remote transmission request this flag reflects the status of the remote transmission request bit in the can frame. in the case of a receive buffer it indicates the status of the received frame and supports the transmission of an answering frame in software. in the case of a transmit buffer, this flag defines the setting of the rtr bit to be sent. 0 = data frame 1 = remote frame 17.12.3 data length register (dlr) this register keeps the data length field of the can frame. dlc3 ? dlc0 ? data length code bits the data length code contains the number of bytes (data byte count) of the respective message. at the transmission of a remote frame, the data length code is transmitted as programmed while the number of transmitted data bytes is always 0. the data byte count ranges from 0 to 8 for a data frame. table 17-3 shows the effect of setting the dlc bits. table 17-3. data length codes data length code data byte count dlc3 dlc2 dlc1 dlc0 00000 00011 00102 00113 01004 01015 01106 01117 10008 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of message storage mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 337 17.12.4 data segment registers (dsrn) the eight data segment registers contain the data to be transmitted or being received. the number of bytes to be transmitted or being received is determined by the data length code in the corresponding dlr. 17.12.5 transmit buffer priority registers (tbpr) prio7 ? prio0 ? local priority this field defines the local priority of the associated message buffer. the local priority is used for the internal prioritisation process of the mscan12 and is defined to be highest for the smallest binary number. the mscan12 implements the following internal prioritisation mechanism:  all transmission buffers with a cleared txe flag participate in the prioritisation immediately before the sof (start of frame) is sent.  the transmission buffer with the lowest local priority field wins the prioritisation.  in cases of more than one buffer having the same lowest priority, the message buffer with the lower index number wins. note: to ensure data integrity, no registers of the transmit buffers shall be written while the associated txe flag is cleared. to ensure data integrity, no registers of the receive buffer shall be read while the rxf flag is cleared. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tbpr (1) 1. x is 5, 6, or 7 depending on which buffer tx0, tx1, or tx2 respectively. r prio7 prio6 prio5 prio4 prio3 prio2 prio1 prio0 $01xd w reset - - - - - - - - f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 338 mscan controller motorola 17.13 programmer ? s model of control registers 17.13.1 overview the programmer ? s model has been laid out for maximum simplicity and efficiency. 17.13.2 mscan12 module control register 0 (cmcr0) cswai ? can stops in wait mode 0 = the module is not affected during wait mode. 1 = the module ceases to be clocked during wait mode. synch ? synchronized status this bit indicates whether the mscan12 is synchronized to the can bus and as such can participate in the communication process. 0 = mscan12 is not synchronized to the can bus 1 = mscan12 is synchronized to the can bus tlnken ? timer enable this flag is used to establish a link between the mscan12 and the on- chip timer (see timer link ). 0 = the port is connected to the timer input. 1 = the mscan12 timer signal output is connected to the timer input. slpak ? sleep mode acknowledge this flag indicates whether the mscan12 is in module internal sleep mode. it shall be used as a handshake for the sleep mode request (see mscan12 sleep mode ). 0 = wake-up ? the mscan12 is not in sleep mode. 1 = sleep ? the mscan12 is in sleep mode. bit 7654321bit 0 cmcr0 r 0 0 cswai synch tlnken slpak slprq sftres $0100 w reset 00100001 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 339 slprq ? sleep request this flag allows to request the mscan12 to go into an internal power- saving mode (see mscan12 sleep mode ). 0 = wake-up ? the mscan12 will function normally. 1 = sleep request ? the mscan12 will go into sleep mode when the can bus is idle, i.e. the module is not receiving a message and all transmit buffers are empty. sftres ? soft_reset when this bit is set by the cpu, the mscan12 immediately enters the soft_reset state. any ongoing transmission or reception is aborted and synchronisation to the bus is lost. the following registers will go into and stay in the same state as out of hard reset: cmcr0, crflg, crier, ctflg, ctcr. the registers cmcr1, cbtr0, cbtr1, cidac, cidar0 ? 3, cidmr0 ? 3 can only be written by the cpu when the mscan12 is in soft_reset state. the values of the error counters are not affected by soft_reset. when this bit is cleared by the cpu, the mscan12 will try to synchronize to the can bus: if the mscan12 is not in busoff state it will be synchronized after 11 recessive bits on the bus; if the mscan12 is in busoff state it continues to wait for 128 occurrences of 11 recessive bits. clearing sftres and writing to other bits in cmcr0 must be in separate instructions. 0 = normal operation 1 = mscan12 in soft_reset state. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 340 mscan controller motorola 17.13.3 mscan12 module control register (cmcr1) loopb ? loop back self test mode when this bit is set the mscan12 performs an internal loop back which can be used for self test operation: the bit stream output of the transmitter is fed back to the receiver internally. the rxcan input pin is ignored and the txcan output goes to the recessive state (1). the mscan12 behaves as it normally does while transmitting and treats its own transmitted message as a message received from a remote node. in this state the mscan12 ignores the bit sent during the ack slot of the can frame acknowledge field to ensure proper reception of its own message. both transmit and receive interrupts are generated. 0 = normal operation 1 = activate loop back self test mode wupm ? wake-up mode this flag defines whether the integrated low-pass filter is applied to protect the mscan12 from spurious wake-ups (see programmable wake-up function ). 0 = mscan12 will wake up the cpu after any recessive to dominant edge on the can bus. 1 = mscan12 will wake up the cpu only in the case of dominant pulse on the bus which has a length of at least approximately t wup . clksrc ? mscan12 clock source this flag defines which clock source the mscan12 module is driven from (only for system with cgm module; see clock system , figure 17-7 ). 0 = the mscan12 clock source is extali. 1 = the mscan12 clock source is sysclk, twice the frequency of eclk. note: the cmcr1 register can be written only if the sftres bit in cmcr0 is set. bit 7654321bit 0 cmcr1 r 0 0 0 0 0 loopb wupm clksrc $0101 w reset 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 341 17.13.4 mscan12 bus timing register 0 (cbtr0) sjw1, sjw0 ? synchronization jump width the synchronization jump width defines the maximum number of time quanta (tq) clock cycles by which a bit may be shortened, or lengthened, to achieve resynchronization on data transitions on the bus (see table 17-4 ). brp5 ? brp0 ? baud rate prescaler these bits determine the time quanta (tq) clock, which is used to build up the individual bit timing, according to table 17-5 . note: the cbtr0 register can only be written if the sftres bit in cmcr0 is set. bit 7654321bit 0 cbtr0 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 $0102 w reset 0 0000000 table 17-4. synchronization jump width sjw1 sjw0 synchronization jump width 0 0 1 tq clock cycle 0 1 2 tq clock cycles 1 0 3 tq clock cycles 1 1 4 tq clock cycles table 17-5. baud rate prescaler brp5 brp4 brp3 brp2 brp1 brp0 prescaler value (p) 000000 1 000001 2 000010 3 000011 4 :::::: : :::::: : 111111 64 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 342 mscan controller motorola 17.13.5 mscan12 bus timing register 1 (cbtr1) samp ? sampling this bit determines the number of samples of the serial bus to be taken per bit time. if set three samples per bit are taken, the regular one (sample point) and two preceding samples, using a majority rule. for higher bit rates samp should be cleared, which means that only one sample will be taken per bit. 0 = one sample per bit. 1 = three samples per bit (1) . tseg22 ? tseg10 ? time segment time segments within the bit time fix the number of clock cycles per bit time, and the location of the sample point. time segment 1 (tseg1) and time segment 2 (tseg2) are programmable as shown in table 17-7 . bit 7654321bit 0 cbtr1 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 $0103 w reset 00000000 1. in this case, phase_seg1 must be at least two time quanta. table 17-6. time segment syntax sync_seg system expects transitions to occur on the bus during this period. transmit point a node in transmit mode will transfer a new value to the can bus at this point. sample point a node in receive mode will sample the bus at this point. if the three samples per bit option is selected then this point marks the position of the third sample. table 17-7. time segment values tseg13 tseg12 tseg11 tseg10 time segment 1 tseg22 tseg21 tseg20 time segment 2 0 0 0 0 1 tq clock cycle 0 0 0 1 tq clock cycle 0 0 0 1 2 tq clock cycles 0 0 1 2 tq clock cycles 0 0 1 0 3 tq clock cycles . . . . 0 0 1 1 4 tq clock cycles . . . . . . . . . 1 1 1 8 tq clock cycles .... . 1 1 1 1 16 tq clock cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 343 the bit time is determined by the oscillator frequency, the baud rate prescaler, and the number of time quanta (tq) clock cycles per bit (as shown above). note: the cbtr1 register can only be written if the sftres bit in cmcr0 is set. 17.13.6 mscan12 receiver flag register (crflg) all bits of this register are read and clear only. a flag can be cleared by writing a 1 to the corresponding bit position. a flag can only be cleared when the condition which caused the setting is no more valid. writing a 0 has no effect on the flag setting. every flag has an associated interrupt enable flag in the crier register. a hard or soft reset clears the register. wupif ? wake-up interrupt flag if the mscan12 detects bus activity while in sleep mode, it sets the wupifflag. if not masked, a wake-up interrupt is pending while this flag is set. 0 = no wake-up activity has been observed while in sleep mode. 1 = mscan12 has detected activity on the bus and requested wake-up. rwrnif ? receiver warning interrupt flag this flag is set when the mscan12 goes into warning status due to the receive error counter (rec) exceeding 96 and neither one of the error interrupt flags or the bus-off interrupt flag is set (1) . if not masked, an error interrupt is pending while this flag is set. 0 = no receiver warning status has been reached. 1 = mscan12 went into receiver warning status. bittime presc value ? ? tt = bit 7654321bit 0 crflg r wupif rwrnif twrnif rerrif terrif boffif ovrif rxf $0104 w reset00000000 1. condition to set the flag: rwrnif = (96 < rec ??? ? ?? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 344 mscan controller motorola twrnif ? transmitter warning interrupt flag this flag is set when the mscan12 goes into warning status due to the transmit error counter (tec) exceeding 96 and neither one of the error interrupt flags or the bus-off interrupt flag is set (1) . if not masked, an error interrupt is pending while this flag is set. 0 = no transmitter warning status has been reached. 1 = mscan12 went into transmitter warning status. rerrif ? receiver error passive interrupt flag this flag is set when the mscan12 goes into error passive status due to the receive error counter (rec) exceeding 127 and the bus-off interrupt flag is not set (2) . if not masked, an error interrupt is pending while this flag is set. 0 = no receiver error passive status has been reached. 1 = mscan12 went into receiver error passive status. terrif ? transmitter error passive interrupt flag this flag is set when the mscan12 goes into error passive status due to the transmit error counter (tec) exceeding 127 and the bus-off interrupt flag is not set (3) . if not masked, an error interrupt is pending while this flag is set. 0 = no transmitter error passive status has been reached. 1 = mscan12 went into transmitter error passive status. boffif ? busoff interrupt flag this flag is set when the mscan12 goes into busoff status, due to the transmit error counter exceeding 255. it cannot be cleared before the mscan12 has monitored 128 times 11 consecutive recessive bits on the bus. if not masked, an error interrupt is pending while this flag is set. 0 = no busoff status has been reached. 1 = mscan12 went into busoff status. 1. condition to set the flag: twrnif = (96 < tec ??? ? ?? ????????? ?? ??? ????????? ?? ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 345 ovrif ? overrun interrupt flag this flag is set when a data overrun condition occurs. if not masked, an error interrupt is pending while this flag is set. 0 = no data overrun has occurred. 1 = a data overrun has been detected. rxf ? receive buffer full the rxf flag is set by the mscan12 when a new message is available in the foreground receive buffer. this flag indicates whether the buffer is loaded with a correctly received message. after the cpu has read that message from the receive buffer the rxf flag must be handshaken (cleared) in order to release the buffer. a set rxf flag prohibits the exchange of the background receive buffer into the foreground buffer. if not masked, a receive interrupt is pending while this flag is set. 0 = the receive buffer is released (not full). 1 = the receive buffer is full. a new message is available. warning: to ensure data integrity, no registers of the receive buffer shall be read while the rxf flag is cleared . note: the crflg register is held in the reset state when the sftres bit in cmcr0 is set. 17.13.7 mscan12 receiver interrupt enable register (crier) wupie ? wake-up interrupt enable 0 = no interruptis generated from this event. 1 = a wake-up event results in a wake-up interrupt. rwrnie ? receiver warning interrupt enable 0 = no interruptis generated from this event. 1 = a receiver warning status event results in an error interrupt. bit 7654321bit 0 crier r wupie rwrnie twrnie rerrie terrie boffie ovrie rxfie $0105 w reset 00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 346 mscan controller motorola twrnie ? transmitter warning interrupt enable 0 = no interruptis generated from this event. 1 = a transmitter warning status event results in an error interrupt. rerrie ? receiver error passive interrupt enable 0 = no interruptis generated from this event. 1 = a receiver error passive status event results in an error interrupt. terrie ? transmitter error passive interrupt enable 0 = no interruptis generated from this event. 1 = a transmitter error passive status event results in an error interrupt. boffie ? busoff interrupt enable 0 = no interruptis generated from this event. 1 = a busoff event results in an error interrupt. ovrie ? overrun interrupt enable 0 = no interruptis generated from this event. 1 = an overrun event results in an error interrupt. rxfie ? receiver full interrupt enable 0 = no interruptis generated from this event. 1 = a receive buffer full (successful message reception) event results in a receive interrupt. note: the crier register is held in the reset state when the sftres bit in cmcr0 is set. 17.13.8 mscan12 transmitter flag register (ctflg) the abort acknowledge flags are read only. the transmitter buffer empty flags are read and clear only. a flag can be cleared by writing a1 to the corresponding bit position. writing a zero has no effect on the flag setting. the transmitter buffer empty flags each have an associated f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 347 interrupt enable flag in the ctcr register. a hard or soft reset will reset the register. abtak2 ? abtak0 ? abort acknowledge this flag acknowledges that a message has been aborted due to a pending abort request from the cpu. after a particular message buffer has been flagged empty, this flag can be used by the application software to identify whether the message has been aborted successfully or has been sent in the meantime. the abtakx flag is cleared implicitly whenever the corresponding txe flag is cleared. 0 = the massage has not been aborted, thus has been sent out. 1 = the message has been aborted. txe2 ? txe0 ? transmitter buffer empty this flag indicates that the associated transmit message buffer is empty, thus not scheduled for transmission. the cpu must handshake (clear) the flag after a message has been set up in the transmit buffer and is due for transmission. the mscan12 sets the flag after the message has been sent successfully. the flag is also set by the mscan12 when the transmission request was successfully aborted due to a pending abort request ( mscan12 transmitter control register (ctcr) ). if not masked, a transmit interrupt is pending while this flag is set. clearing a txex flag also clears the corresponding abtakx flag (see above). when a txex flag is set, the corresponding abtrqx bit is cleared (see mscan12 transmitter control register (ctcr) ). 0 = the associated message buffer is full (loaded with a message due for transmission). 1 = the associated message buffer is empty (not scheduled). warning: to ensure data integrity, no registers of the transmit buffers should be written to while the associated txe flag is cleared . bit 7654321bit 0 ctflg r 0 abtak2 abtak1 abtak0 0 txe2 txe1 txe0 $0106 w reset 0 0 0 0 0 1 1 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 348 mscan controller motorola note: the ctflg register is held in the reset state if the sftres bit in cmcr0 is set. 17.13.9 mscan12 transmitter control register (ctcr) abtrq2 ? abtrq0 ? abort request the cpu sets an abtrqx bit to request that a scheduled message buffer (txex = 0) shall be aborted. the mscan12 grants the request if the message has not already started transmission or if the transmission is not successful (lost arbitration or error). when a message is aborted, the associated txe and the abort acknowledge flag (abtak, see mscan12 transmitter flag register (ctflg) ) are set and an txe interrupt is generated if enabled. the cpu cannot reset abtrqx. abtrqx is cleared implicitly whenever the associated txe flag is set. 0 = no abort request. 1 = abort request pending. note: the software must not clear one or more of the txe flags in ctfgl and simultaneously set the respective abtrq bit(s). txeie2 ? txeie0 ? transmitter empty interrupt enable 0 = no interruptis generated from this event. 1 = a transmitter empty (transmit buffer available for transmission) event results in a transmitter empty interrupt. note: the ctcr register is held in the reset state when the sftres bit in cmcr0 is set. bit 7654321bit 0 ctcr r 0 abtrq2 abtrq1 abtrq0 0 txeie2 txeie1 txeie0 $0107 w reset 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 349 17.13.10 mscan12 identifier acceptance control register (cidac) idam1 ? idam0 ? identifier acceptance mode the cpu sets these flags to define the identifier acceptance filter organisation (see identifier acceptance filter ). table 17-7 summarizes the different settings. in filter closed mode no messages are accepted such that the foreground buffer is never reloaded. idhit2 ? idhit0 ? identifier acceptance hit indicator the mscan12 sets these flags to indicate an identifier acceptance hit (see identifier acceptance filter ). table 17-7 summarizes the different settings. the idhit indicators are always related to the message in the foreground buffer. when a message gets copied from the background to the foreground buffer the indicators are updated as well. note: the cidac register can only be written if the sftres bit in cmcr0 is set. bit 7654321bit 0 cidac r 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 $0108 w reset 0 0 0 0 0 0 0 0 table 17-8. identifier acceptance mode settings idam1 idam0 identifier acceptance mode 0 0 two 32 bit acceptance filters 0 1 four 16 bit acceptance filters 1 0 eight 8 bit acceptance filters 1 1 filter closed table 17-9. identifier acceptance hit indication idhit2 idhit1 idhit0 identifier acceptance hit 000 filter 0 hit 001 filter 1 hit 010 filter 2 hit 011 filter 3 hit 100 filter 4 hit 101 filter 5 hit 110 filter 6 hit 111 filter 7 hit f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 350 mscan controller motorola 17.13.11 mscan12 receive error counter (crxerr) this register reflects the status of the mscan12 receive error counter. the register is read only. 17.13.12 mscan12 transmit error counter (ctxerr) this register reflects the status of the mscan12 transmit error counter. the register is read only. note: both error counters must only be read when in sleep or soft_reset mode. 17.13.13 mscan12 identifier acceptance registers (cidar0 ? 7) on reception each message is written into the background receive buffer. the cpu is only signalled to read the message however, if it passes the criteria in the identifier acceptance and identifier mask registers (accepted); otherwise, the message is overwritten by the next message (dropped). the acceptance registers of the mscan12 are applied on the idr0 to idr3 registers of incoming messages in a bit by bit manner. for extended identifiers all four acceptance and mask registers are applied. for standard identifiers only the first two (cidmr0/1 and cidar0/1) are applied. in the latter case it is required to program the three last bits (am2 ? am0) in the mask register cidmr1 to ? don ? t care ? . bit 7654321bit 0 crxerr r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 $010e w reset 00000000 bit 7654321bit 0 ctxerr r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 $010f w reset 0 0000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller programmer ? s model of control registers mc68hc912dg128 ? rev 3.0 technical data motorola mscan controller 351 ac7 ? ac0 ? acceptance code bits ac7 ? ac0 comprise a user defined sequence of bits with which the corresponding bits of the related identifier register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identifier mask register. note: the cidar0 ? 7 registers can only be written if the sftres bit in cmcr0 is set. 17.13.14 mscan12 identifier mask registers (cidmr0 ? 7) the identifier mask register specifies which of the corresponding bits in the identifier acceptance register are relevant for acceptance filtering. to receive standard identifiers in 32 bit filter mode it is required to program the last three bits (am2 ? am0) in the mask registers cidmr1 and figure 17-14. identifier acceptance registers (1st bank) bit 7654321bit 0 cidar0 r ac7ac6ac5ac4ac3ac2ac1ac0 $0110 w cidar1 r ac7ac6ac5ac4ac3ac2ac1ac0 $0111 w cidar2 r ac7ac6ac5ac4ac3ac2ac1ac0 $0112 w cidar3 r ac7ac6ac5ac4ac3ac2ac1ac0 $0113 w reset-------- figure 17-15. identifier acceptance registers (2nd bank) bit 7654321bit 0 cidar4 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 $0118 w cidar5 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 $0119 w cidar6 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 $011a w cidar7 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 $011b w reset-------- f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 352 mscan controller motorola cidmr5 to ? don ? t care. to receive standard identifiers in 16 bit filter mode it is required to program the last three bits (am2 ? am0) in the mask registers cidmr1, cidmr3, cidmr5 and cidmr7 to ? don ? t care am7 ? am0 ? acceptance mask bits if a particular bit in this register is cleared this indicates that the corresponding bit in the identifier acceptance register must be the same as its identifier bit, before a match is detected. the message is accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identifier acceptance register does not affect whether or not the message is accepted. 0 = match corresponding acceptance code register and identifier bits. 1 = ignore corresponding acceptance code register bit. note: the cidmr0 ? 7 registers can only be written if the sftres bit in cmcr0 is set. figure 17-16. identifier mask registers (1st bank) bit 7654321bit 0 cidmr0 r am7 am6 am5 am4 am3 am2 am1 am0 $0114 w cidmr1 r am7 am6 am5 am4 am3 am2 am1 am0 $0115 w cidmr2 r am7 am6 am5 am4 am3 am2 am1 am0 $0116 w cidmr3 r am7 am6 am5 am4 am3 am2 am1 am0 $0117 w reset-------- figure 17-17. identifier mask registers (2nd bank) bit 7654321bit 0 cidmr4 r am7am6am5am4am3am2am1am0 $011c w cidmr5 r am7am6am5am4am3am2am1am0 $011d w cidmr6 r am7am6am5am4am3am2am1am0 $011e w cidmr7 r am7am6am5am4am3am2am1am0 $011f w reset-------- f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 353 mscan controller motorola 17.13.15 mscan12 port can control register (pctlcan) the following bits control pins 7 through 2 of port can when they are implemented externally. pupcan ? pull-up enable port can 0 = pull mode disabled for port can. 1 = pull mode enabled for port can. rdpcan ? reduced drive port can 0 = reduced drive disabled for port can. 1 = reduced drive enabled for port can. 17.13.16 mscan12 port can data register (portcan) port bits 7 to 2 will read zero when configured as inputs because they are not implemented externally. when configured as output, port bits 7 to 2 will read the last value written. reading bits 1 and 0 returns the value of the txcan and rxcan pins, respectively. 17.13.17 mscan12 port can data direction register (ddrcan) ddcan7 ? ddcan2 ? this bits served as memory locations since there are no corresponding external port pins. bit 7654321bit 0 pctlcanr000000 pupcan rdpcan $013d w reset 0 0000000 bit 7654321bit 0 portcan r pcan7 pcan6 pcan5 pcan4 pcan3 pcan2 txcan rxcan $013e w reset ----- bit 7654321bit 0 ddrcan r ddcan7 ddcan6 ddcan5 ddcan4 ddcan3 ddcan2 00 $013f w reset00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mscan controller technical data mc68hc912dg128 ? rev 3.0 354 mscan controller motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola development support 355 technical data ? mc68hc912dg128 section 18. development support 18.1 contents 18.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 18.3 instruction queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 18.4 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 18.5 breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 18.6 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 18.2 introduction development support involves complex interactions between mc68hc912dg128 resources and external development systems. the following section concerns instruction queue and queue tracking signals, background debug mode, and instruction tagging. 18.3 instruction queue the cpu12 instruction queue provides at least three bytes of program information to the cpu when instruction execution begins. the cpu12 always completely finishes executing an instruction before beginning to execute the next instruction. status signals ipipe[1:0] provide information about data movement in the queue and indicate when the cpu begins to execute instructions. this makes it possible to monitor cpu activity on a cycle-by-cycle basis for debugging. information available on the ipipe[1:0] pins is time multiplexed. external circuitry can latch data movement information on rising edges of the e-clock signal; execution start information can be latched on falling edges. table 18-1 shows the meaning of data on the pins. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 356 development support motorola program information is fetched a few cycles before it is used by the cpu. in order to monitor cycle-by-cycle cpu activity, it is necessary to externally reconstruct what is happening in the instruction queue. internally the mcu only needs to buffer the data from program fetches. for system debug it is necessary to keep the data and its associated address in the reconstructed instruction queue. the raw signals required for reconstruction of the queue are addr, data, r/w , eclk, and status signals ipipe[1:0]. the instruction queue consists of two 16-bit queue stages and a holding latch on the input of the first stage. to advance the queue means to move the word in the first stage to the second stage and move the word from either the holding latch or the data bus input buffer into the first stage. to start even (or odd) instruction means to execute the opcode in the high-order (or low-order) byte of the second stage of the instruction queue. table 18-1. ipipe decoding data movement ? ipipe[1:0] captured at rising edge of e clock (1) 1. refers to data that was on the bus at the previous e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no movement 0:1 lat latch data from bus 1:0 ald advance queue and load from bus 1:1 all advance queue and load from latch execution start ? ipipe[1:0] captured at falling edge of e clock (2) 2. refers to bus cycle starting at this e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no start 0:1 int start interrupt sequence 1:0 sev start even instruction 1:1 sod start odd instruction f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 357 18.4 background debug mode background debug mode (bdm) is used for system development, in- circuit testing, field testing, and programming. bdm is implemented in on-chip hardware and provides a full set of debug options. because bdm control logic does not reside in the cpu, bdm hardware commands can be executed while the cpu is operating normally. the control logic generally uses free cpu cycles to execute these commands, but can steal cycles from the cpu when necessary. other bdm commands are firmware based, and require the cpu to be in active background mode for execution. while bdm is active, the cpu executes a firmware program located in a small on-chip rom that is available in the standard 64-kbyte memory map only while bdm is active. the bdm control logic communicates with an external host development system serially, via the bkgd pin. this single-wire approach minimizes the number of pins needed for development support. 18.4.1 enabling bdm firmware commands bdm is available in all operating modes, but must be made active before firmware commands can be executed. bdm is enabled by setting the enbdm bit in the bdm status register via the single wire interface (using a hardware command; write_bd_byte at $ff01). bdm must then be activated to map bdm registers and rom to addresses $ff00 to $ffff and to put the mcu in active background mode. after the firmware is enabled, bdm can be activated by the hardware background command, by the bdm tagging mechanism, or by the cpu bgnd instruction. an attempt to activate bdm before firmware has been enabled causes the mcu to resume normal instruction execution after a brief delay. bdm becomes active at the next instruction boundary following execution of the bdm background command, but tags activate bdm before a tagged instruction is executed. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 358 development support motorola in special single-chip mode, background operation is enabled and active immediately out of reset. this active case replaces the m68hc11 boot function, and allows programming a system with blank memory. while bdm is active, a set of bdm control registers are mapped to addresses $ff00 to $ff06. the bdm control logic uses these registers which can be read anytime by bdm logic, not user programs. refer to bdm registers for detailed descriptions. some on-chip peripherals have a bdm control bit which allows suspending the peripheral function during bdm. for example, if the timer control is enabled, the timer counter is stopped while in bdm. once normal program flow is continued, the timer counter is re-enabled to simulate real-time operations. 18.4.2 bdm serial interface the bdm serial interface requires the external controller to generate a falling edge on the bkgd pin to indicate the start of each bit time. the external controller provides this falling edge whether data is transmitted or received. bkgd is a pseudo-open-drain pin that can be driven either by an external controller or by the mcu. data is transferred msb first at 16 b- clock cycles per bit (nominal speed). the interface times out if 512 b- clock cycles occur between falling edges from the host. the hardware clears the command register when a time-out occurs. the bkgd pin can receive a high or low level or transmit a high or low level. the following diagrams show timing for each of these cases. interface timing is synchronous to mcu clocks but asynchronous to the external host. the internal clock signal is shown for reference in counting cycles. figure 18-1 shows an external host transmitting a logic one or zero to the bkgd pin of a target mc68hc912dg128 mcu. the host is asynchronous to the target so there is a 0-to-1 cycle delay from the host- generated falling edge to where the target perceives the beginning of the bit time. ten target b cycles later, the target senses the bit level on the bkgd pin. typically the host actively drives the pseudo-open-drain f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 359 bkgd pin during host-to-target transmissions to speed up rising edges. since the target does not drive the bkgd pin during this period, there is no need to treat the line as an open-drain signal during host-to-target transmissions. figure 18-1. bdm host to target serial bit timing figure 18-2. bdm target to host serial bit timing (logic 1) 10 cycles b clock (target mcu) host transmit 1 target senses bit earliest start of next bit synchronization uncertainty perceived start of bit time host transmit 0 10 cycles b clock (target mcu) earliest start of next bit bkgd pin perceived start of bit time 10 cycles host samples bkgd pin host drive to bkgd pin target mcu speedup pulse r-c rise high-impedance high-impedance high-impedance f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 360 development support motorola figure 18-2 shows the host receiving a logic one from the target mc68hc912dg128 mcu. since the host is asynchronous to the target mcu, there is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the perceived start of the bit time in the target mcu. the host holds the bkgd pin low long enough for the target to recognize it (at least two target b cycles). the host must release the low drive before the target mcu drives a brief active-high speed-up pulse seven cycles after the perceived start of the bit time. the host should sample the bit level about ten cycles after it started the bit time. figure 18-3. bdm target to host serial bit timing (logic 0) figure 18-3 shows the host receiving a logic zero from the target mc68hc912dg128 mcu. since the host is asynchronous to the target mcu, there is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the start of the bit time as perceived by the target mcu. the host initiates the bit time but the target mc68hc912dg128 finishes it. since the target wants the host to receive a logic zero, it drives the bkgd pin low for 13 b-clock cycles, then briefly drives it high to speed up the rising edge. the host samples the bit level about ten cycles after starting the bit time. 10 cycles b clock (target mcu) earliest start of next bit bkgd pin perceived start of bit time 10 cycles host samples bkgd pin host drive to bkgd pin target mcu drive and speedup pulse high-impedance speedup pulse f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 361 18.4.3 bdm commands the bdm command set consists of two types: hardware and firmware. hardware commands allow target system memory to be read or written. target system memory includes all memory that is accessible by the cpu12 including eeprom, on-chip i/o and control registers, and external memory that is connected to the target hc12 mcu. hardware commands are implemented in hardware logic and do not require the hc12 mcu to be in bdm mode for execution. the control logic watches the cpu12 buses to find a free bus cycle to execute the command so the background access does not disturb the running application programs. if a free cycle is not found within 128 b-clock cycles, the cpu12 is momentarily frozen so the control logic can steal a cycle. commands implemented in bdm control logic are listed in table 18-2 . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 362 development support motorola the second type of bdm commands are firmware commands implemented in a small rom within the hc12 mcu. the cpu must be in background mode to execute firmware commands. the usual way to get to background mode is by the hardware command background. the bdm rom is located at $ff20 to $ffff while bdm is active. there are also seven bytes of bdm registers located at $ff00 to $ff06 when bdm is active. the cpu executes code in the bdm firmware to perform the requested operation. the bdm firmware watches for serial commands and executes them as they are received. the firmware commands are shown in table 18-3 . table 18-2. hardware commands (1) command opcode (hex) data description background 90 none enter background mode if firmware enabled. read_bd_byte (1) e4 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. read_bd_word (1) ec 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access). must be aligned access. read_byte e0 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. read_word e8 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access). must be aligned access. write_bd_byte (1) c4 16-bit address 16-bit data in write to memory with bdm in map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. write_bd_word (1) cc 16-bit address 16-bit data in write to memory with bdm in map (may steal cycles if external access). must be aligned access. write_byte c0 16-bit address 16-bit data in write to memory with bdm out of map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. write_word c8 16-bit address 16-bit data in write to memory with bdm out of map (may steal cycles if external access). must be aligned access. 1. use these commands only for reading/writing to bdm locations . the bdm firmware rom and bdm registers are not normally in the hc12 mcu memory map . since these locations have the same addresses as some of the normal application memory map, there needs to be a way to decide which physical locations are being accessed by the hardware bdm commands . this gives rise to needing separate memory access commands for the bdm locations as opposed to the normal application lo- cations . in logic, this is accomplished by momentarily enabling the bdm memory resources, just for the access cycles of the read_bd and write_bd commands . this logic allows the debugging system to unobtrusively access the bdm locations even if the application program is running out of the same memory area in the normal application memory map . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 363 each of the hardware and firmware bdm commands start with an 8-bit command code (opcode). depending upon the commands, a 16-bit address and/or a 16-bit data word is required as indicated in the tables by the command. all the read commands output 16-bits of data despite the byte/word implication in the command name. the external host should wait 150 bclk cycles for a non-intrusive bdm command to execute before another command is sent. this delay includes 128 bclk cycles for the maximum delay for a free cycle. for data read commands, the host must insert this delay between sending the address and attempting to read the data. in the case of a write command, the host must delay after the data portion before sending a new command to be sure that the write has finished. the external host should delay about 32 target bclk cycles between a firmware read command and the data portion of these commands. this allows the bdm firmware to execute the instructions needed to get the requested data into the bdm shifter register. table 18-3. bdm firmware commands command opcode (hex) data description read_next 62 16-bit data out x = x + 2; read next word pointed to by x read_pc 63 16-bit data out read program counter read_d 64 16-bit data out read d accumulator read_x 65 16-bit data out read x index register read_y 66 16-bit data out read y index register read_sp 67 16-bit data out read stack pointer write_next 42 16-bit data in x = x + 2; write next word pointed to by x write_pc 43 16-bit data in write program counter write_d 44 16-bit data in write d accumulator write_x 45 16-bit data in write x index register write_y 46 16-bit data in write y index register write_sp 47 16-bit data in write stack pointer go 08 none go to user program trace1 10 none execute one user instruction then return to bdm taggo 18 none enable tagging and go to user program f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 364 development support motorola the external host should delay about 32 target bclk cycles after the data portion of firmware write commands to allow bdm firmware to complete the requested write operation before a new serial command disturbs the bdm shifter register. the external host should delay about 64 target bclk cycles after a trace1 or go command before starting any new serial command. this delay is needed because the bdm shifter register is used as a temporary data holding register during the exit sequence to user code. bdm logic retains control of the internal buses until a read or write is completed. if an operation can be completed in a single cycle, it does not intrude on normal cpu12 operation. however, if an operation requires multiple cycles, cpu12 clocks are frozen until the operation is complete. 18.4.4 bdm lockout the access to the mcu resources by bdm may be prevented by enabling the bdm lockout feature. when enabled, the bdm lockout mechanism prevents the bdm from being active. in this case the bdm rom is disabled and does not appear in the mcu memory map. bdm lockout is enabled by clearing nobdml bit of eemcr register. the nobdml bit is loaded at reset from the shadow byte of eeprom module. modifying the state of the nobdml and corresponding eeprom shadow bit is only possible in special modes. please refer to eeprom memory for nobdml information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 365 18.4.4.1 enabling bdm lockout enabling the bdm lockout feature is only possible in special modes (smodn=0) and is accomplished by the following steps. 1. remove the shadow byte protection by clearing shprot bit in eeprot register. 2. clear noshb bit in eemcr register to make the shadow byte visible at $0fc0. 3. program bit 7 of the shadow byte like a regular eeprom location at address $0fc0 (write $7f into address $0fc0). do not program other bits of the shadow byte (location $0fc0); otherwise some regular eeprom array locations will not be visible. at the next reset, the shadow byte is loaded into the eemcr register. nobdml bit in eemcr will be cleared and bdm will not be operational. 4. protect the shadow byte by setting shprot bit in eeprot register. 18.4.4.2 disabling bdm lockout disabling the bdm lockout is only possible in special modes (smodn=0). follow the same steps as for enabling the bdm lockout, but erase the shadow byte. at the next reset, the shadow byte is loaded into the eemcr register. nobdml bit in eemcr will be set and bdm becomes operational. note: when the bdm lockout is enabled it is not possible to run code from the reset vector in special single chip mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 366 development support motorola 18.4.5 bdm registers seven bdm registers are mapped into the standard 64-kbyte address space when bdm is active. mapping is shown in table 18-4 .  the instruction register content is determined by the type of background command being executed.  the status register indicates bdm operating conditions.  the shift register contains data being received or transmitted via the serial interface.  the address register is temporary storage for bdm commands.  the ccrsav register preserves the content of the cpu12 ccr while bdm is active. the only registers of interest to users are the status register and the ccrsav register. the other bdm registers are only used by the bdm firmware to execute commands. the registers are accessed by means of the hardware read_bd and write_bd commands, but should not be written during bdm operation (except the ccrsav register which could be written to modify the ccr value). table 18-4. bdm registers address register $ff00 bdm instruction register $ff01 bdm status register $ff02 ? $ff03 bdm shift register $ff04 ? $ff05 bdm address register $ff06 bdm ccr holding register f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 367 18.4.5.1 status the status register is read and written by the bdm hardware as a result of serial data shifted in on the bkgd pin. read: all modes. write: bits 3 through 5, and bit 7 are writable in all modes. bit 6, bdmact, can only be written if bit 7 h/f in the instruction register is a zero. bit 2, clksw, can only be written if bit 7 h/f in the instruction register is a one. a user would never write ones to bits 3 through 5 because these bits are only used by bdm firmware. enbdm ? enable bdm (permit active background debug mode) 0 = bdm cannot be made active (hardware commands still allowed). 1 = bdm can be made active to allow firmware commands. bdmact ? background mode active status bdmact becomes set as active bdm mode is entered so that the bdm firmware rom is enabled and put into the map. bdmact is cleared by a carefully timed store instruction in the bdm firmware as part of the exit sequence to return to user code and remove the bdm memory from the map. this bit has 4 clock cycles write delay. 0 = bdm is not active. bdm rom and registers are not in map. 1 = bdm is active and waiting for serial commands. bdm rom and registers are in map bit 7654321bit 0 enbdm bdmact entag sdv trace clksw - - reset: 0 (note 1) 1000000 special single chip & periph reset: 00000000 all other modes status ? bdm status register (1) $ff01 1. enbdm is set to 1 by the firmware in special single chip mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 368 development support motorola the user should be careful that the state of the bdmact bit is not unintentionally changed with the write_next firmware command. if it is unintentionally changed from 1 to 0, it will cause a system runaway because it would disable the bdm firmware rom while the cpu12 was executing bdm firmware. the following two commands show how bdmact may unintentionally get changed from 1 to 0. write_x with data $fefe write_next with data $c400 the first command writes the data $fefe to the x index register. the second command writes the data $c4 to the $ff00 instruction register and also writes the data $00 to the $ff01 status register. entag ? tagging enable set by the taggo command and cleared when bdm mode is entered. the serial system is disabled and the tag function enabled 16 cycles after this bit is written. 0 = tagging not enabled, or bdm active. 1 = tagging active. bdm cannot process serial commands while tagging is active. sdv ? shifter data valid shows that valid data is in the serial interface shift register. used by the bdm firmware. 0 = no valid data. shift operation is not complete. 1 = valid data. shift operation is complete. trace ? asserted by the trace1 command clksw ? clock switch 0 = bdm system operates with bclk. 1 = bdm system operates with eclk. the write_bd_byte@ff01 command that changes clksw including 150 cycles after the data portion of the command should be timed at the old speed. beginning with the start of the next bdm command, the new clock can be used for timing bdm communications. if eclk rate is slower than bclk rate, clksw is ignored and bdm system is forced to operate with eclk. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 369 18.4.5.2 instruction - hardware instruction decode the instruction register is written by the bdm hardware as a result of serial data shifted in on the bkgd pin. it is readable and writable in special peripheral mode on the parallel bus. it is discussed here for two conditions: when a hardware command is executed and when a firmware command is executed. read and write: all modes the hardware clears the instruction register if 512 bclk cycles occur between falling edges from the host. the bits in the bdm instruction register have the following meanings when a hardware command is executed. h/f ? hardware/firmware flag 0 = firmware command 1 = hardware command data ? data flag - shows that data accompanies the command. 0 = no data 1 = data follows the command r/w ? read/write flag 0 = write 1 = read bkgnd ? hardware request to enter active background mode 0 = not a hardware background command 1 = hardware background command (instruction = $90) bit 7654321bit 0 h/f data r/w bkgnd w/b bd/u 0 0 reset: 0 0 0 0 0 0 0 0 instruction ? bdm instruction register (hardware command explanation) $ff00 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 370 development support motorola w/b ? word/byte transfer flag 0 = byte transfer 1 = word transfer bd/u ? bdm map/user map flag indicates whether bdm registers and rom are mapped to addresses $ff00 to $ffff in the standard 64-kbyte address space. used only by hardware read/write commands. 0 = bdm resources not in map 1 = bdm rom and registers in map the bits in the bdm instruction register have the following meanings when a firmware command is executed. h/f ? hardware/firmware flag 0 = firmware command 1 = hardware command data ? data flag - shows that data accompanies the command. 0 = no data 1 = data follows the command r/w ? read/write flag 0 = write 1 = read bit 7654321bit 0 h/f data r/w ttago regn instruction ? bdm instruction register (firmware command bit explanation) $ff00 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 371 ttago ? trace, tag, go field regn ? register/next field indicates which register is being affected by a command. in the case of a read_next or write_next command, index register x is pre-incriminated by 2 and the word pointed to by x is then read or written. table 18-5. ttago decoding table 18-6ttago value table 18-7instruction 00 ? 01 go 10 trace1 11 taggo table 18-8. regn decoding regn value instruction 000 ? 001 ? 010 read/write next 011 pc 100 d 101 x 110 y 111 sp f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 372 development support motorola 18.4.5.3 shifter this 16-bit shift register contains data being received or transmitted via the serial interface. it is also used by the bdm firmware for temporary storage. read: all modes (but not normally accessed by users) write: all modes (but not normally accessed by users) bit 15 14 13 12 11 10 9 bit 8 s15 s14 s13 s12 s11 s10 s9 s8 reset: xxxxxxxx shifter ? bdm shift register - high byte $ff02 bit 7654321bit 0 s7 s6 s5 s4 s3 s2 s1 s0 reset: xxxxxxxx shifter ? bdm shift register - low byte $ff03 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support background debug mode mc68hc912dg128 ? rev 3.0 technical data motorola development support 373 18.4.5.4 address this 16-bit address register is temporary storage for bdm hardware and firmware commands. read: all modes (but not normally accessed by users) write: only by bdm hardware (state machine) bit 15 14 13 12 11 10 9 bit 8 a15 a14 a13 a12 a11 a10 a9 a8 reset: xxxxxxxx address ? bdm address register - high byte $ff04 bit 7654321bit 0 a7 a6 a5 a4 a3 a2 a1 a0 reset: xxxxxxxx address ? bdm address register - low byte $ff05 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 374 development support motorola 18.4.5.5 ccrsav the ccrsav register is used to save the ccr of the users program when entering bdm. it is also used for temporary storage in the bdm firmware. read and write: all modes bit 7654321bit 0 ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 reset: note 1 (1) xxxxxxxx ccrsav ? bdm ccr holding register $ff06 1. initialized to equal the cpu12 ccr register by the firmware. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support breakpoints mc68hc912dg128 ? rev 3.0 technical data motorola development support 375 18.5 breakpoints hardware breakpoints are used to debug software on the mc68hc912dg128 by comparing actual address and data values to predetermined data in setup registers. a successful comparison will place the cpu in background debug mode (bdm) or initiate a software interrupt (swi). breakpoint features designed into the mc68hc912dg128 include:  mode selection for bdm or swi generation  program fetch tagging for cycle of execution breakpoint  second address compare in dual address modes  range compare by disable of low byte address  data compare in full feature mode for non-tagged breakpoint  byte masking for high/low byte data compares  r/w compare for non-tagged compares  tag inhibit on bdm trace 18.5.1 breakpoint modes three modes of operation determine the type of breakpoint in effect.  dual address-only breakpoints, each of which will cause a software interrupt (swi)  single full-feature breakpoint which will cause the part to enter background debug mode (bdm)  dual address-only breakpoints, each of which will cause the part to enter bdm breakpoints will not occur when bdm is active. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 376 development support motorola 18.5.1.1 swi dual address mode in this mode, dual address-only breakpoints can be set, each of which cause a software interrupt. this is the only breakpoint mode which can force the cpu to execute a swi. program fetch tagging is the default in this mode; data breakpoints are not possible. in the dual mode each address breakpoint is affected by the bkpm bit and the bkale bit. the bkxrw and bkxrwe bits are ignored. in dual address mode the bkdbe becomes an enable for the second address breakpoint. the bksz8 bit will have no effect when in a dual address mode. 18.5.1.2 bdm full breakpoint mode a single full feature breakpoint which causes the part to enter background debug mode. bdm mode may be entered by a breakpoint only if an internal signal from the bdm indicates background debug mode is enabled.  breakpoints are not allowed if the bdm mode is already active. active mode means the cpu is executing out of the bdm rom.  bdm should not be entered from a breakpoint unless the enable bit is set in the bdm. this is important because even if the enable bit in the bdm is negated the cpu actually does execute the bdm rom code. it checks the enable and returns if not set. if the bdm is not serviced by the monitor then the breakpoint would be re-asserted when the bdm returns to normal cpu flow.  there is no hardware to enforce restriction of breakpoint operation if the bdm is not enabled. 18.5.1.3 bdm dual address mode dual address-only breakpoints, each of which cause the part to enter background debug mode. in the dual mode each address breakpoint is affected, consistent across modes, by the bkpm bit, the bkale bit, and the bkxrw and bkxrwe bits. in dual address mode the bkdbe becomes an enable for the second address breakpoint. the bksz8 bit will have no effect when in a dual address mode. bdm mode may be f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support breakpoints mc68hc912dg128 ? rev 3.0 technical data motorola development support 377 entered by a breakpoint only if an internal signal from the bdm indicates background debug mode is enabled.  bkdbe will be used as an enable for the second address only breakpoint.  breakpoints are not allowed if the bdm mode is already active. active mode means the cpu is executing out of the bdm rom.  bdm should not be entered from a breakpoint unless the enable bit is set in the bdm. this is important because even if the enable bit in the bdm is negated the cpu actually does execute the bdm rom code. it checks the enable and returns if not set. if the bdm is not serviced by the monitor then the breakpoint would be re-asserted when the bdm returns to normal cpu flow. there is no hardware to enforce restriction of breakpoint operation if the bdm is not enabled. 18.5.2 breakpoint registers breakpoint operation consists of comparing data in the breakpoint address registers (brkah/brkal) to the address bus and comparing data in the breakpoint data registers (brkdh/brkdl) to the data bus. the breakpoint data registers can also be compared to the address bus. the scope of comparison can be expanded by ignoring the least significant byte of address or data matches. the scope of comparison can be limited to program data only by setting the bkpm bit in breakpoint control register 0. to trace program flow, setting the bkpm bit causes address comparison of program data only. control bits are also available that allow checking read/write matches. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 378 development support motorola read and write anytime. this register is used to control the breakpoint logic. bken1, bken0 ? breakpoint mode enable bkpm ? break on program addresses this bit controls whether the breakpoint will cause a break on a match (next instruction boundary) or on a match that will be an executable opcode. data and non-executed opcodes cannot cause a break if this bit is set. this bit has no meaning in swi dual address mode. the swi mode only performs program breakpoints. 0 = on match, break at the next instruction boundary 1 = on match, break if the match is an instruction that will be executed. this uses tagging as its breakpoint mechanism. bk1ale ? breakpoint 1 range control only valid in dual address mode. 0 = brkdl will not be used to compare to the address bus. 1 = brkdl will be used to compare to the address bus. bk0ale ? breakpoint 0 range control valid in all modes. 0 = brkal will not be used to compare to the address bus. 1 = brkal will be used to compare to the address bus. bit 7654321bit 0 bken1 bken0 bkpm 0 bk1ale bk0ale 0 0 reset:00000000 brkct0 ? breakpoint control register 0 $0020 table 18-9. breakpoint mode control bken1 bken0 mode selected brkah/l usage brkdh/l usage r/w range 0 0 breakpoints off ???? 01swi ? dual address mode address match address match no yes 10bdm ? full breakpoint mode address match data match yes yes 11bdm ? dual address mode address match address match yes yes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support breakpoints mc68hc912dg128 ? rev 3.0 technical data motorola development support 379 this register is read/write in all modes. bkdbe ? enable data bus enables comparing of address or data bus values using the brkdh/l registers. 0 = the brkdh/l registers are not used in any comparison 1 = the brkdh/l registers are used to compare address or data (depending upon the mode selections bken1,0) bkmbh ? breakpoint mask high disables the comparing of the high byte of data when in full breakpoint mode. used in conjunction with the bkdbe bit (which should be set) 0 = high byte of data bus (bits 15:8) are compared to brkdh 1 = high byte is not used in comparisons bkmbl ? breakpoint mask low disables the matching of the low byte of data when in full breakpoint mode. used in conjunction with the bkdbe bit (which should be set) 0 = low byte of data bus (bits 7:0) are compared to brkdl 1 = low byte is not used in comparisons. table 18-10. breakpoint address range control bk1ale bk0ale address range selected ? 0 upper 8-bit address only for full mode or dual mode bkp0 ? 1 full 16-bit address for full mode or dual mode bkp0 0 ? upper 8-bit address only for dual mode bkp1 1 ? full 16-bit address for dual mode bkp1 bit 7654321bit 0 0 bkdbe bkmbh bkmbl bk1rwe bk1rw bk0rwe bk0rw reset: 0 0 0 0 0 0 0 0 brkct1 ? breakpoint control register 1 $0021 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 380 development support motorola bk1rwe ? r/w compare enable enables the comparison of the r/w signal to further specify what causes a match. this bit is not useful in program breakpoints or in full breakpoint mode. this bit is used in conjunction with a second address in dual address mode when bkdbe=1. 0 = r/w is not used in comparisons 1 = r/w is used in comparisons bk1rw ? r/w compare value when bk1rwe = 1, this bit determines the type of bus cycle to match. 0 = a write cycle will be matched 1 = a read cycle will be matched bk0rwe ? r/w compare enable enables the comparison of the r/w signal to further specify what causes a match. this bit is not useful in program breakpoints. 0 = r/w is not used in the comparisons 1 = r/w is used in comparisons bk0rw ? r/w compare value when bk0rwe = 1, this bit determines the type of bus cycle to match on. 0 = write cycle will be matched 1 = read cycle will be matched table 18-11. breakpoint read/write control bk1rwe bk1rw bk0rwe bk0rw read/write selected ?? 0xr/w is don ? t care for full mode or dual mode bkp0 ?? 10r/w is write for full mode or dual mode bkp0 ?? 11r/w is read for full mode or dual mode bkp0 0x ?? r/w is don ? t care for dual mode bkp1 10 ?? r/w is write for dual mode bkp1 11 ?? r/w is read for dual mode bkp1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 381 development support motorola these bits are used to compare against the most significant byte of the address bus. these bits are used to compare against the least significant byte of the address bus. these bits may be excluded from being used in the match if bk0ale = 0. these bits are compared to the most significant byte of the data bus or the most significant byte of the address bus in dual address modes. bken[1:0], bkdbe, and bkmbh control how this byte will be used in the breakpoint comparison. bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 reset: 0 0 000000 brkah ? breakpoint address register, high byte $0022 bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 000000 brkal ? breakpoint address register, low byte $0023 bit 7654321bit 0 bit 15 14 13 12 11 10 9 bit 8 reset: 0 0 000000 brkdh ? breakpoint data register, high byte $0024 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 382 development support motorola these bits are compared to the least significant byte of the data bus or the least significant byte of the address bus in dual address modes. bken[1:0], bkdbe, bk1ale, and bkmbl control how this byte will be used in the breakpoint comparison. 18.6 instruction tagging the instruction queue and cycle-by-cycle cpu activity can be reconstructed in real time or from trace history that was captured by a logic analyzer. however, the reconstructed queue cannot be used to stop the cpu at a specific instruction, because execution has already begun by the time an operation is visible outside the mcu. a separate instruction tagging mechanism is provided for this purpose. executing the bdm taggo command configures two mcu pins for tagging. the taglo signal shares a pin with the lstrb signal, and the taghi signal shares a pin with the bkgd signal. tagging information is latched on the falling edge of eclk. table 18-12 shows the functions of the two tagging pins. the pins operate independently - the state of one pin does not affect the function of the other. the presence of logic level zero on either pin at the fall of eclk performs the indicated function. tagging is allowed in all modes. tagging is disabled when bdm becomes active and bdm serial commands are not processed while tagging is active. bit 7654321bit 0 bit 7654321bit 0 reset: 0 0 000000 brkdl ? breakpoint data register, low byte $0025 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support instruction tagging mc68hc912dg128 ? rev 3.0 technical data motorola development support 383 the tag follows program information as it advances through the queue. when a tagged instruction reaches the head of the queue, the cpu enters active background debugging mode rather than execute the instruction. table 18-12. tag pin function taghi taglo tag 1 1 no tag 10 low byte 0 1 high byte 0 0 both bytes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
development support technical data mc68hc912dg128 ? rev 3.0 384 development support motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 385 technical data ? mc68hc912dg128 section 19. electrical specifications 19.1 contents 19.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 19.3 tables of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 19.2 introduction the mc68hc912dg128 microcontroller unit (mcu) is a16-bit device composed of standard on-chip peripherals including a 16-bit central processing unit (cpu12), 128-kbyte flash eeprom, 8k byte ram, 2k byte eeprom, two asynchronous serial communications interfaces (sci), a serial peripheral interface (spi), an 8-channel, 16-bit timer, two16-bit pulse accumulators and 16-bit down counter (ect), two 10-bit analog-to-digital converter (adc), a four-channel pulse-width modulator (pwm), an iic interface module, and two mscan modules. the chip is the first 16-bit microcontroller to include both byte-erasable eeprom and flash eeprom on the same device. system resource mapping, clock generation, interrupt control and bus interfacing are managed by the lite integration module (lim). the mc68hc912dg128 has full 16- bit data paths throughout, however, the multiplexed external bus can operate in an 8-bit narrow mode so single 8-bit wide memory can be interfaced for lower cost systems. this section contains the most accurate electrical information for the mc68hc912dg128 microcontroller available at the time of publication. the following characteristics are contained in this document: f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 386 electrical specifications motorola 19.3 tables of data table 19-1. maximum ratings (1) 1. permanent damage can occur if maximum ratings are exceeded. exposures to voltages or currents in excess of recommend- ed values affects device reliability. device modules may not operate normally while being exposed to electrical extremes. rating symbol value unit supply voltage v dd , v dda , v ddx ? ?? + ? ? ?? + ?? ?? ?? + ? ?? + ? ?? + ? ?? + ?? ? ?? + ??? ? ?? ????????????????? ????????????????? ?????????????? ????????????????? ? ??? ?? ? ??? ?? ? + ? ? ? ? ??? ???? ?? ??????? ? + ? ? ??? ? ? ??? ???? ? ? p int and can be neglected. p i/o user-determined w a constant (3) 3. k is a constant pertaining to the device. solve for k with a known t a and a measured p d (at equilibrium). use this value of k to solve for p d and t j iteratively for any value of t a . k p d ? ? + ? ? + ? ? ? ? ? t j 273 c + ------------------------- - f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 387 table 19-3. dc electrical characteristics v dd = ??? ]? ? = ??? ? = ? ?? ??? ???? ? ? + ???? ? ? ????????? ?? ? = ? ? ? ? = ? ? ? ?? ? = ? ? ? ? = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? v v v v output low voltage, all i/o and output pins except xtal normal drive strength i ol = ?? ? = ?? ?? ? = ?? ? = ?? ? ? ? ? v ss + + + + ?? ? ? = ? ? ? ????? ?? ? ?????? ? ? ?????? ?? ?? ? ? ? 10 15 20 pf pf pf output load capacitance all outputs except ps[7:4] ps[7:4] when configured as spi c l ? ? 90 200 pf pf programmable active pull-up/pull-down current irq , xirq , dbe , lstrb , r/w . ports a, b, h, j, k, p, s, t, ib[7:4], rxcan1, .rxcan0 moda, modb active pull down during reset bkgd passive pull up i apu 50 50 50 500 500 500 ???? ? ? v f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 388 electrical specifications motorola ram standby current i sb ? 50 ?? ? ? ? ? ? 0.3v, v postclamp =v dde +0.3) steady state single pin limit steady state package limit includes sum of all stressed pins (25 pins max.) transient single pin limit transient package limit includes sum of all stressed pins (25 pins max.) i icsss i icssp i ictrs i ictrp ? 0.5 ? 10 ? 25 ? 25 0.5 10 25 25 ma 1. specification is for parts in the -40 to +85 ????????? ? ?? ? ?????? ??????? ????????? ?? ?? ?? ??????????????????? ??????????????? ???????? ?? ?????? ?????? ?? ???? ?? ???? ?? ?????????????? ??? ??????????????????? ???????????????????? ???????? ???? ? = ??? ]? ? = ??? ? = ? ?? ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 389 table 19-4. supply current v dd = ??? ]? ? = ??? ? = ? ?? ??? ? ??? ? ? ????? ? ? ??? ????? ? = ??? ]? ? = ??? ? = ? ?? ??? = ????? ? ?? ??? ?? / ?? / ??? ? ? ??? ?? ?? ????? ? ? ? ? = ?? ] ?????? ? ? ? ? ? ? ? ? ??????????????? ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 390 electrical specifications motorola table 19-6. analog converter characteristics (operating) v dd = ??? ]? ? = ??? ? = ? ?? ??? = ????? ? ? ?? ? + ?? ? + ?? ??????? ? + ? ? ?? ? 2 2 count 10-bit integral non-linearity (2) inl ? 2 2 count 10-bit absolute error (3) 2, 4, 8, and 16 atd sample clocks ae ? 2.5 2.5 count maximum source impedance r s 20 see note (4) k ? ? ? ? ? ? ? ? ? ? ? = ? ?? ?????????????? ?????????????????? ?????????????? ??????????????? ?????????? ?????????????????? ????????? ? = ? ? ? ????????????????? ???????????????? ? = ?? ? ? ? ? ? ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 391 table 19-7. atd ac characteristics (operating) v dd = ??? ]? ? = ??? ? = ? ?? ??? = ????? ? ??? ??? ??? ? ? ??? ? ? ?????? ?? ????????????????????? ??? ???????? ?????????????? ???? ?? ? ? ? ? ? ?? + ? ?? + ?? | ? | ?? ? ? ?? | ? | ???? | ? | f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 392 electrical specifications motorola table 19-9. eeprom characteristics v dd = ??? ]? ? = ??? ? = ? ?? ??? ? ??? ? ??????? + ? ? ? ? ??????????? ? < ? ??? ??? ???? ? = ??? ]? ? = ??? ? = ? ?? ??? ?? ? ???? ? + ?? ? ?? ?? ??? ? ??? ? ] ??? ? ? 10 ms erase to verify time t verase 1 ms erase margin e m 100 (1) % program/erase endurance 100 cycles data retention 10 years 1. the number of margin pulses required is the same as the number of pulses used to program or erase. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 393 use of an external circuit to condition v fp is recommended. figure 19-1 shows a simple circuit that maintains required voltages and filters transients. v fp is pulled to v dd via schottky diode d2. application of programming voltage via diode reverse-biases d2, protecting v dd from excessive reverse current. d2 also protects the flash from damage should programming voltage go to 0. programming power supply voltage must be adjusted to compensate for the forward-bias drop across d1. the charge time constant of r1 and c1 filters transients, while r2 provides a discharge bleed path to c1. allow for rc charge and discharge time constants when applying and removing power. when using this circuit, keep leakage from external devices connected to the v fp pin low, to minimize diode voltage drop. figure 19-1. v fp conditioning circuit d1 r1 22k ? ? ? ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 394 electrical specifications motorola figure 19-2. v fp operating range 13.5v 12.8v 11.4v 6.5v 4.5v 4.15v 0v ? 0.30v power on normal read power down program erase verify t er 30ns maximum v fp envelope v dd envelope combined v dd and v fp table 19-11. pulse width modulator characteristics v dd = ??? ]? ? = ??? ? = ? ?? ??? ? ? ? ? ?? ?? ?? ?? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 395 1. reset is recognized during the first clock cycle it is held low. internal circuitry then drives the pin low for 16 clock cycles, releases the pin, and samples the pin level 8 cycles later to determine the source of the interrupt. figure 19-3. timer inputs table 19-12. control timing characteristic symbol 8.0 mhz unit min max frequency of operation f o 0.004 8.0 mhz e-clock period t cyc 0.125 250 ?? ??? ? = ? / + ? ? ns reset input pulse width to guarantee external reset vector minimum input time (can be preempted by internal reset) pw rstl 32 2 ? ? t cyc t cyc mode programming setup time t mps 4 ? t cyc mode programming hold time t mph 10 ? ns interrupt pulse width, irq edge-sensitive mode pw irq = ? ? + ? ? ns wait recovery startup time t wrs ? 4cycles timer input capture pulse width (pw tim = 2 t cyc + 20) pw tim 270 ? ns 1. when using a quartz crystal, operation should be restricted to 8mhz. pt7 2 pt7 1 pt[7:0] 2 pt[7:0] 1 notes : 1. rising edge sensitive input 2. falling edge sensitive input pw tim pw pa f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 396 electrical specifications motorola figure 19-4. por and external reset timing diagram t pcsu internal moda, modb eclk extal v dd reset 4098 t cyc free fffe fffe 3rd 1st 2nd free fffe fffe fffe t mph pw rstl t mps address pipe pipe pipe 1st exec 3rd pipe 2nd pipe 1st pipe 1st exec note: reset timing is subject to change. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 397 figure 19-5. stop recovery timing diagram pw irq t stopdelay 3 irq 1 irq or xirq eclk 1st address 4 sp-9 free free vector free free resume program with instruction which follows the stop instruction. internal address 5 clocks notes: 1. edge sensitive irq pin (irqe bit = 1) 2. level sensitive irq pin (irqe bit = 0) 3. t stopdelay = 4098 t cyc if dly bit = 1 or 2 t cyc if dly = 0. 4. xirq with x bit in ccr = 1. 5. irq or (xirq with x bit in ccr = 0). opt 1st 2nd 3rd 1st exec pipe pipe exec sp-8 sp-6 fetch pipe sp-6 sp-8 sp-9 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 398 electrical specifications motorola figure 19-6. wait recovery timing diagram t pcsu pc, iy, ix, b:a, , ccr stack registers eclk r/w address irq , xirq , or internal interrupts sp ? 2 sp ? 4 sp ? 6 . . . sp ? 9 sp ? 9 sp ? 9 . . . sp ? 9 sp ? 9 vector free 1st 2nd 3rd pipe t wrs note: reset also causes recovery from wait. address pipe pipe 1st exec f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 399 figure 19-7. interrupt timing diagram eclk pw irq 1st 3rd address irq 1 sp ? 9 t pcsu irq 2 , xirq , or internal interrupt vector sp ? 2 1st sp ? 4 sp ? 6 2nd sp ? 8 data vect pc iy ix b:a ccr prog r/w notes: 1. edge sensitive irq pin (irqe bit = 1) 2. level sensitive irq pin (irqe bit = 0) fetch addr exec pipe pipe pipe prog fetch prog fetch f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 400 electrical specifications motorola figure 19-8. port read timing diagram figure 19-9. port write timing diagram table 19-13. peripheral port timing characteristic symbol 8.0 mhz unit min max frequency of operation (e-clock frequency) f o 0.004 8.0 mhz e-clock period t cyc 0.125 250 ???? ?? ?? ??? ? ns peripheral data hold time mcu read of ports t pdh 0 ? ns delay time, peripheral data write mcu write to ports t pwd ? 40 ns port rd tim eclk mcu read of port ports t pdsu t pdh port wr tim eclk mcu write to port previous port data new data valid port a t pwd f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 401 table 19-14. multiplexed expansion bus timing v dd = ??? ?]? ? = ??? ? = ? ?? ??? ??? ???????? ????????]??]? ? ???? ? ? = ? / ? t cyc 0.125 250 ??? ? = ? / ? + ? ??? ? = / ? + ? ?? ? = ? / ? + ? ????? ? = ? ? ? ? t av 0ns 8 multiplexed address hold timet mah = ? / ? + ? ? ???? ? t ahds 20 10 data hold to high zt dhz = ? ? ? ? ? t dhz 38 11 read data setup time ? t dsr 25 ns 12 read data hold time ? t dhr 10 ns 13 write data delay time ? t ddw 47 ns 14 write data hold time ? t dhw 20 ns 15 write data setup time (5) t dsw = ? ? ? ? ? t dsw 13 ns 16 read/write delay timet rwd = ? / ? + ? ????? ? = ? ? ? ? t rwv 9ns 18 read/write hold time ? t rwh 20 ns 19 low strobe (6) delay timet lsd = ? / ? + ? ? ????? ? = ? ? ? ? t lsv 9ns 21 low strobe (6) hold time ? t lsh 20 ns 22 address access time (5) t acca = ? ? ? ? ? ? ? t acca 42 ns 23 access time from e rise (5) t acce = ? ? ? ? t acce 35 ns 24 dbe delay from eclk rise (5) t dbed = ? / ? + ? ?? ? = ? ? ? ? t dbe 21 ns 26 dbe hold time from eclk fall t dbeh ? 310ns f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 402 electrical specifications motorola figure 19-10. multiplexed expansion bus timing diagram 3. reduced drive must be off to meet these timings. 4. unequalled loading of pins will affect relative timing numbers. 5. this characteristic is affected by clock stretch. add n ? ?????????????? ??? dbe 24 25 eclk r/w 1 2 3 18 11 12 14 note: measurement points shown are 20% and 70% of v dd 13 16 17 read write 23 lstrb 21 19 20 (w/o tag enabled) 5 7 22 8 15 address/data multiplexed address address data data 10 9 26 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 403 table 19-15. spi timing (v dd = ??? ]? ? = ??? ? = ? ?? ???????? ? / / ? ? ? t cyc t cyc enable lead time master slave t lead 1 / ? ? t sck t cyc enable lag time master slave t lag 1 / ? ? t sck t cyc clock (sck) high or low time master slave t wsck t cyc ? ? ? ? ? ? ? ns ns sequential transfer delay master slave t td 1 / ? ? t sck t cyc data setup time (inputs) master slave t su 30 30 ? ? ns ns data hold time (inputs) master slave t hi 0 30 ? ? ns ns slave access time t a ? 1 t cyc slave miso disable time t dis ? 1 t cyc data valid (after sck edge) master slave t v ? ? 50 50 ns ns data hold time (outputs) master slave t ho 0 0 ? ? ns ns rise time input output t ri t ro ? ? t cyc ? ? ? ? ? t cyc ? ? ?????????]? ??]? ???? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 404 electrical specifications motorola a) spi master timing (cpha = 0) b) spi master timing (cpha = 1) figure 19-11. spi timing diagram (1 of 2) sck (output) sck (output) miso (input) mosi (output) ss 1 (output) 1 10 6 7 msb in 2 bit 6 . . . 1 lsb in msb out 2 lsb out bit 6 . . . 1 11 4 4 2 10 (cpol = 0) (cpol = 1) 5 3 12 13 1. ss output mode (dds7 = 1, ssoe = 1). 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb. sck (output) sck (output) miso (input) mosi (output) 1 6 7 msb in 2 bit 6 . . . 1 lsb in master msb out 2 master lsb out bit 6 . . . 1 4 4 10 12 13 11 port data (cpol = 0) (cpol = 1) port data ss 1 (output) 5 2 13 12 3 1. ss output mode (dds7 = 1, ssoe = 1). 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications tables of data mc68hc912dg128 ? rev 3.0 technical data motorola electrical specifications 405 a) spi slave timing (cpha = ? ????? = ? ??????? sck (input) sck (input) mosi (input) miso (output) ss (input) 1 10 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 11 4 4 2 8 (cpol = 0) (cpol = 1) 5 3 13 note: not defined but normally msb of character just received. slave 13 12 11 see 12 note 9 spi slave cpha1 sck (input) sck (input) mosi (input) miso (output) 1 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 4 4 10 12 13 11 see (cpol = 0) (cpol = 1) ss (input) 5 2 13 12 3 note: not defined but normally lsb of character just received. slave note 8 9 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
electrical specifications technical data mc68hc912dg128 ? rev 3.0 406 electrical specifications motorola table 19-16. cgm characteristics 5.0 volts +/- 10% characteristic symbol min. typ. max. unit pll reference frequency, crystal oscillator range f ref 0.5 8 mhz bus frequency f bus 0.004 8 mhz vco range f vco 2.5 8 mhz vco limp-home frequency f vcomin 0.5 2.5 mhz lock detector transition from acquisition to tracking mode (1) ? ] ] ? lock detection ? ] ] ? un-lock detection ? ] ] ? lock detector transition from tracking to acquisition mode ? ] ] ? minimum leakage resistance on crystal oscillator pins r leak 1m ? ?? ??? ???? ???? ??? ???????????????? ???? ???????????? ???????? ? ? ?? ? ????[???[????????? ? ??? ???? ????? ??????? ?????]? ???? ?? ?? ??? ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 407 technical data ? mc68hc912dg128 section 20. appendix: cgm practical aspects 20.1 contents 20.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 20.3 a few hints for the cgm crystal oscillator application. . . . 407 20.4 practical aspects for the pll usage . . . . . . . . . . . . . . . . . . 410 20.5 printed circuit board guidelines. . . . . . . . . . . . . . . . . . . . . . . 415 20.2 introduction this sections provides useful and practical pieces of information concerning the implementation of the cgm module. 20.3 a few hints for the cgm crystal oscillator application 20.3.1 what loading capacitors to choose? first, from small-signal analysis, it is known that relatively large values for c1 and c2 have a positive impact on the phase margin. however, the higher loading they represent decreases the loop gain. alternatively, small values for these capacitors will lead to higher open loop gain, but as the frequency of oscillation approaches the parallel resonance, the phase margin, and consequently the ability to start-up correctly, will decrease. from this it is clear that relatively large capacitor values (>33pf), are reserved for low frequency crystals in the mhz range. note: using the recommended loading capacitor cl value from the crystal manufacturer is a good starting point. taking into account unavoidable strays, this equates to about (cl-2pf). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 408 appendix: cgm practical aspects motorola theoretically speaking, nothing precludes the use of non-identical values for c1 and c2. as this complicate a bit the management of the final board device list, this is not recommended. however, if asymmetrical capacitors are chosen, the value of c1 should be higher than c2 (because the reflected loading is proportional to the square of the impedance of c2). 20.3.2 dc bias due to the nature of the translated ground colpitts oscillator a dc voltage bias is applied to the crystal. please contact the crystal manufacturer for specific dc bias conditions and recommended capacitance value (if applicable). 20.3.3 what is the final oscillation frequency? the exact calculation is not straightforward as it takes into account the resonator characteristics and the loading capacitors values as well as internal design parameters which can vary with process voltage temperature (pvt) conditions. nevertheless, if l is the series inductance, r is the series resistance, c is the series capacitance and cc the parallel capacitance of the crystal, we can then use the following simplified equation: 20.3.4 how do i control the peak to peak oscillation amplitude? the cgm oscillator is equipped with an amplitude limitation control loop which integrates the peak to peak ? extal ? amplitude and in return reduces the steady current of the transconductor device until a stable fosc 1 2 ------ 1 lc ------- - 1 lccc1c2 || + () ? ---------------------------------------------- + ? = c1=c2=cl yields to fosc 1 2 ------ 1 lc ------- - 1 lcccl2 ? + () ? --------------------------------------- + ? = f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects a few hints for the cgm crystal oscillator application mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 409 quiescent point is reached. controlling this final peak to peak amplitude can be performed by three means: 1. reducing the values of c1 and c2. this decreases the loading so that the necessary gm value required to sustain oscillation can be smaller. the consequently smaller current will be reached with a larger ? extal ? swing. 2. using vddpll=vss (i.e. shutting off the pll). doing so increases the starting current by approximately 50%. all other parameters staying the same, a larger ? extal ? swing will be required to reduce this starting current to its quiescent value. 3. also, placing a high value resistor (>1m ? ????? ??????? ?????????? ?? ????? ? ????? ???????????? ?????????? ???????? ????????? ??????????? ???????????? ??? ?????? ??????????? ???????????? ????????? ????????????? ????????? ??????????? ????? ????????? ????????? ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 410 appendix: cgm practical aspects motorola 20.4 practical aspects for the pll usage 20.4.1 synthesized bus frequency starting from a ceramic resonator or quartz crystal frequency f xtal , if ? refdv ? and ? synr ? are the decimal content of the refdv and synr registers respectively, then the mcu bus frequency will simply be: note: it is not allowed to synthesize a bus frequency that is lower than the crystal frequency, as the correct functioning of some internal synchronizers would be jeopardized (e.g. the mclk and xclk clock generators). 20.4.2 operation under adverse environmental conditions the normal operation for the pll is the so-called ? automatic bandwidth selection mode ? which is obtained by having the auto bit set in the pllcr register. when this mode is selected and as the vco frequency approaches its target, the charge pump current level will automatically switch from a relatively high value of around 40 ?????? ?? ????????????? ????????????? ??????? ?????????? ???????????? ? hunts ? between acquisition and tracking modes. it is then advised for the running software to place the pll in manual, forced acquisition mode by clearing both the auto and the acq bits in the pllcr register. doing so will maintain the high current level in the charge pump constantly and will permit to sustain higher levels of leakages at the xfc pin. this latest revision of the clock generator module maintains the lock detection f bus f vco f xtal synr 1 + () ? refdv 1 + () ----------------------------------------------- - == synr 0,1,2,3...63} { refdv 0,1,2,3...7} { f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects practical aspects for the pll usage mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 411 feature even in manual bandwidth control, offering then to the application software the same flexibility for the clocking control as the automatic mode. 20.4.3 filter components selection guide 20.4.3.1 equations set these equations can be used to select a set of filter components. two cases are considered: 1. the ? tracking ? mode. this situation is reached normally when the pll operates in automatic bandwidth selection mode (auto=1 in the pllcr register). 2. the ? acquisition ? mode. this situation is reached when the pll operates in manual bandwidth selection mode and forced acquisition (auto=0, acq =0 in the pllcr register). in both equations, the power supply should be 5v. start with the target loop bandwidth as a function of the other parameters, but obviously, nothing prevents the user from starting with the capacitor value for example. also, remember that the smoothing capacitor is always assumed to be one tenth of the series capacitance value. so with: m: the multiplying factor for the reference frequency (i.e. (synr+1)) r: the series resistance of the low pass filter in ? ????????? ?????? ??? ?????? ?? ? tracking ? mode: f c 210 9 2 ?? rc ?? ------------------------- 37.78 e 1.675 f bus ? 10.795 ----------------------------- ?? ?? r ?? 2 m ?? ----------------------------------------------------- - == f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 412 appendix: cgm practical aspects motorola and for the ? acquisition ? mode: 20.4.3.2 particular case of an 8mhz synthesis assume that a desired value for the damping factor of the second order system is close to 0.9 as this leads to a satisfactory transient response. then, derived from the equations above, table 20-1 and table 20-2 suggest sets of values corresponding to several loop bandwidth possibilities in the case of an 8mhz synthesis for the two cases mentioned above. the filter components values are chosen from standard series (e.g. e12 for resistors). the operating voltage is assumed to be 5v (although there is only a minor difference between 3v and 5v operation). the smoothing capacitor cp in parallel with r 0 and c 0 is set to be 1/10 of the value of c 0 . the reference frequencies mentioned in this table correspond to the output of the fine granularity divider controlled by the refdv register. this means that the calculations are irrespective of the way the reference frequency is generated (directly for the crystal oscillator or after division). the target frequency value also has an influence on the calculations of the filter components because the vco gain is not constant over its operating range. the bandwidth limit corresponds to the so-called gardner ? s criteria. it corresponds to the maximum value that can be chosen before the continuous time approximation ceases to be justified. it is of course advisable to stay far away from this limit. f c 210 9 2 ?? rc ?? ------------------------- 415.61 e 1.675 f bus ? 10.795 ----------------------------- ?? ?? ?? ?? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects practical aspects for the pll usage mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 413 table 20-1. suggested 8mhz synthesis pll filter elements (tracking mode) reference [mhz] synr fbus [mhz] c 0 [nf] r 0 [k ? ? ? ? ? ? ? [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 414 appendix: cgm practical aspects motorola table 20-2. suggested 8mhz synthesis pll filter elements (acquisition mode) reference [mhz] synr fbus [mhz] c 0 [nf] r 0 [k ? ? ? ? ? ? [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects printed circuit board guidelines mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 415 20.5 printed circuit board guidelines printed circuit boards (pcbs) are the board of choice for volume applications. if designed correctly, a very low noise system can be built on a pcb with consequently good emi/emc performances. if designed incorrectly, pcbs can be extremely noisy and sensitive modules, and the cgm could be disrupted. some common sense rules can be used to prevent such problems.  use a ? star ? style power routing plan as opposed to a ? daisy chain ? . route power and ground from a central location to each chip individually, and use the widest trace practical (the more the chip draws current, the wider the trace). never place the mcu at the end of a long string of serially connected chips.  when using pcb layout software, first direct the routing of the power supply lines as well as the cgm wires (crystal oscillator and pll). layout constraints must be then reported on the other signals and not on these ? hot ? nodes. optimizing the ? hot ? nodes at the end of the routing process usually gives bad results.  avoid notches in power traces. these notches not only add resistance (and are not usually accounted for in simulations), but they can also add unnecessary transmission line effects.  avoid ground and power loops. this has been one of the most violated guidelines of pcb layout. loops are excellent noise transmitters and can be easily avoided. when using multiple layer pcbs, the power and ground plane concept works well but only when strictly adhered to (do not compromise the ground plane by cutting a hole in it and running signals on the ground plane layer). keep the spacing around via holes to a minimum (but not so small as to add capacitive effects).  be aware of the three dimensional capacitive effects of multi- layered pcbs.  bypass (decouple) the power supplies of all chips as close to the chip as possible. use one decoupling capacitor per power supply pair (vdd/vss, vddx/vssx...). two capacitors with a ratio of about 100 sometimes offer better performances over a broader f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 416 appendix: cgm practical aspects motorola spectrum. this is especially the case for the power supply pins close to the e port, when the e clock and/or the calibration clock are used.  on the general vdd power supply input, a ? t ? low pass filter lcl can be used (e.g. 10 ?? ? t ? is preferable to the ? ? version as the exhibited impedance is more constant with respect to the vdd current. like many modular micro controllers, hc12 devices have a power consumption which not only varies with clock edges but also with the functioning modes.  keep high speed clock and bus trace length to a minimum. the higher the clock speed, the shorter the trace length. if noisy signals are sent over long tracks, impedance adjustments should be considered at both ends of the line (generally, simple resistors suffice).  bus drivers like the can physical interface should be installed close to their connector, with dedicated filtering on their power supply.  mount components as close to the board as possible. snip excess lead length as close to the board as possible. preferably use surface mount devices (smds).  mount discrete components as close to the chip that uses them as possible.  do not cross sensitive signals on any layer. if a sensitive signal must be crossed by another signal, do it as many layers away as possible and at right angles.  always keep pcbs clean. solder flux, oils from fingerprints, humidity and general dirt can conduct electricity. sensitive circuits can easily be disrupted by small amounts of leakage.  choose pcb coatings with care. certain epoxies, paints, gelatins, plastics and waxes can conduct electricity. if the manufacturer cannot provide the electrical characteristics of the substance, do not use it. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects printed circuit board guidelines mc68hc912dg128 ? rev 3.0 technical data motorola appendix: cgm practical aspects 417 in addition to the above general pieces of advice, the following guidelines should be followed for the cgm pins (but also more generally for any sensitive analog circuitry):  parasitic capacitance on extal is absolutely critical ? probably the most critical layout consideration. the xtal pin is not as sensitive. all routing from the extal pin through the resonator and the blocking cap to the actual connection to vss must be considered.  for minimum capacitance there should ideally be no ground / power plane around the extal pin and associated routing. however, practical emc considerations obviously should be taken into consideration for each application.  the clock input circuitry is sensitive to noise so excellent supply routing and decoupling is mandatory. connect the ground point of the oscillator circuit directly to the vsspll pin.  good isolation of pll / oscillator power supply is critical. use 1nf+ 100nf and keep tracks as low impedance as possible  load capacitors should be low leakage and stable across temperature ? use npo or c0g types.  the load capacitors may ? pull ? the target frequency by a few ppm. crystal manufacturer specs show symmetrical values but the series device capacitance on extal and xtal are not symmetrical. it may be possible to adjust this by changing the values of the load capacitors ? start-up conditions should be evaluated.  keep the adjacent port h / port e and reset signals noise free. don ? t connect these to external signals and / or add series filtering ? a series resistor is probably adequate.  any dc-blocking capacitor should be as low esr as possible ? for the range of crystals we are looking at anything over 1 ohm is too much.  mount oscillator components on mcu side of board ? avoid using vias in the oscillator circuitry. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: cgm practical aspects technical data mc68hc912dg128 ? rev 3.0 418 appendix: cgm practical aspects motorola  mount the pll filter and oscillator components as close to the mcu as possible.  do not allow the extal and xtal signals to interfere with the xfc node. keep these tracks as short as possible.  do not cross the cgm signals with any other signal on any level.  remember that the reference voltage for the xfc filter is vddpll.  as the return path for the oscillator circuitry is vsspll, it is extremely important to connect vsspll to vss even if the pll is not to be powered. surface mount components reduce the susceptibility of signal contamination.  ceramic resonators with built-in capacitors are available. this is an interesting solution because the parasitic components involved are minimized due to the close proximity of the resonating elements. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a flash 419 technical data ? mc68hc912dg128 section 21. appendix: mc68hc912dg128a flash 21.1 contents 21.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 21.3 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 21.4 flash eeprom control block . . . . . . . . . . . . . . . . . . . . . . . . 420 21.5 flash eeprom arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 21.6 flash eeprom registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 21.7 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423 21.8 programming the flash eeprom . . . . . . . . . . . . . . . . . . . . . 424 21.9 erasing the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . 425 21.10 stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425 21.2 introduction the four flash eeprom array modules 00fee32k, 01fee32k, 10fee32k and 11fee32k for the 68hc912dg128a serve as electrically erasable and programmable, non-volatile rom emulation memory. the modules can be used for program code that must either execute at high speed or is frequently executed, such as operating system kernels and standard subroutines, or they can be used for static data which is read frequently. the flash eeprom module is ideal for program storage for single-chip applications allowing for field reprogramming. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash technical data mc68hc912dg128 ? rev 3.0 420 appendix: mc68hc912dg128a flash motorola 21.3 overview each 32k flash eeprom array is arranged in a 16-bit configuration and may be read as either bytes, aligned words or misaligned words. access time is one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. programming is by aligned word. the flash eeprom module supports bulk erase only. each flash eeprom module has hardware interlocks which protect stored data from accidental corruption. an erase- and program- protected 8-kbyte block for boot routines is located at the top of each 32- kbyte array. since boot programs must be available at all times, the only useful boot block is at $e000 ? $ffff location. all paged boot blocks can be used as protected program space if desired. 21.4 flash eeprom control block a 4-byte register block for each module controls the flash eeprom operation. configuration information is specified and programmed independently from the contents of the flash eeprom array. at reset, the 4-byte register section starts at address $00f4 and points to the 00fee32k register block. 21.5 flash eeprom arrays after reset, a fixed 32k flash eeprom array, 11fee32k, is located from addresses $4000 to $7fff and from $c000 to $ffff. the other three 32k flash eeprom arrays 00fee32k, 01fee32k and 10fee32k, are mapped through a 16k byte program page window located from addresses $8000 to $bfff. the page window has eight 16k byte pages. the last two pages also map the physical location of the fixed 32k flash eeprom array 11fee32k. in expanded modes, the flash eeprom arrays are turned off. see operating modes . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash flash eeprom registers mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a flash 421 21.6 flash eeprom registers each 32k byte flash eeprom module has a set of registers. the register space $00f4-$00f7 is in a register space window of four pages. each register page of four bytes maps the register space for each flash module and each page is selected by the ppage register. see operating modes . in normal modes the lock bit can only be written once after reset. lock ? lock register bit 0 = enable write to feemcr register 1 = disable write to feemcr register this register controls the operation of the flash eeprom array. bootp cannot be changed when the lock control bit in the feelck register is set or if enpe in the feectl register is set. bootp ? boot protect the boot blocks are located at $e000 ? $ffff and $a000 ? $bfff for odd program pages for each flash eeprom module. since boot programs must be available at all times, the only useful boot block is at $e000 ? $ffff location. all paged boot blocks can be used as protected program space if desired. 0 = enable erase and program of 8k byte boot block 1 = disable erase and program of 8k byte boot block feelck ? flash eeprom lock control register $00f4 bit 7 6 5 4 3 2 1 bit 0 0 0 0 0 0 0 0 lock reset: 0 0 0 0 0 0 0 0 feemcr ? flash eeprom module configuration register $00f5 bit 7 6 5 4 3 2 1 bit 0 0 0 0 0 0 0 0 bootp reset: 0 0 0 0 0 0 0 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash technical data mc68hc912dg128 ? rev 3.0 422 appendix: mc68hc912dg128a flash motorola this register controls the programming and erasure of the flash eeprom. feeswai ? flash eeprom stop in wait control 0 = do not halt flash eeprom clock when the part is in wait mode. 1 = halt flash eeprom clock when the part is in wait mode. hven ? high-voltage enable this bit enables the charge pump to supply high voltages for program and erase operations in the array. hven can only be set if either pgm or eras are set and the proper sequence for program or erase is followed. 0 = disables high voltage to array and charge pump off 1 = enables high voltage to array and charge pump on eras ? erase control this bit configures the memory for erase operation. eras is interlocked with the pgm bit such that both bits cannot be equal to 1 or set to1 at the same time. 0 = erase operation is not selected. 1 = erase operation selected. pgm ? program control this bit configures the memory for program operation. pgm is interlocked with the eras bit such that both bits cannot be equal to 1 or set to1 at the same time. 0 = program operation is not selected. 1 = program operation selected. feectl ? flash eeprom control register $00f7 bit 7 6 5 4 3 2 1 bit 0 0 0 0 feeswai hven 0 eras pgm reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash operation mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a flash 423 21.7 operation the flash eeprom can contain program and data. on reset, it can operate as a bootstrap memory to provide the cpu with internal initialization information during the reset sequence. 21.7.1 bootstrap operation single-chip mode after reset, the cpu controlling the system will begin booting up by fetching the first program address from address $fffe. 21.7.2 normal operation the flash eeprom allows a byte or aligned word read in one bus cycle. misaligned word read require an additional bus cycle. the flash eeprom array responds to read operations only. write operations are ignored. 21.7.3 program/erase operation an unprogrammed flash eeprom bit has a logic state of one. a bit must be programmed to change its state from one to zero. erasing a bit returns it to a logic one. the flash eeprom has a minimum program/erase life of 100 cycles. programming or erasing the flash eeprom is accomplished by a series of control register writes. programming is restricted to aligned word at a time as determined by internal signal sz8 and addr[0]. the flash eeprom must first be completely erased prior to programming final data values. programming and erasing of flash locations cannot be performed by code being executed from the flash memory. while these operations must be performed in the order shown, other unrelated operations may occur between the steps. do not exceed t fpgm maximum (40 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash technical data mc68hc912dg128 ? rev 3.0 424 appendix: mc68hc912dg128a flash motorola 21.8 programming the flash eeprom programming the flash eeprom is done on a row basis. a row consists of 64 consecutive bytes starting from addresses $xx00, $xx40, $xx80 and $xxc0. use this step-by-step procedure to program a row of flash memory. 1. set the pgm bit. this configures the memory for program operation and enables the latching of address and data for programming. 2. write to any flash address with any data within the row address range desired. 3. wait for a time, t nvs (min. 10 ??? ???? ?? ????????????? ?????????? ??????? ???? ? ? ????????????? ??? ???? ?? ??? ?? ?? ???????? ? ??????????? ????????? ??????????? ???? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash erasing the flash eeprom mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a flash 425 21.9 erasing the flash eeprom the following sequence demonstrates the recommended procedure for erasing any of the flash eeprom array. 1. set the eras bit. 2. write to any valid address in the flash array. the data written and the address written are not important. the boot block will be erased only if the control bit bootp is negated. 3. wait for a time, t nvs (min. 10 ???? ???? ??? ???? ???? ?? ??? ?? ?? ???????? ? ????? ???????????? ????????????? ???? ?????????????? ??????? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a flash technical data mc68hc912dg128 ? rev 3.0 426 appendix: mc68hc912dg128a flash motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 427 technical data ? mc68hc912dg128 section 22. appendix: mc68hc912dg128a eeprom 22.1 contents 22.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 22.3 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . . 428 22.4 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 430 22.5 program/erase operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 22.6 shadow word mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . .436 22.7 programming eedivh and eedivl registers. . . . . . . . . . . . 437 22.2 introduction the 68hc912dg128a eeprom nonvolatile memory is arranged in a 16-bit configuration. the eeprom array may be read as either bytes, aligned words or misaligned words. access times are one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. programming is by byte or aligned word. attempts to program or erase misaligned words will fail. only the lower byte will be latched and programmed or erased. programming and erasing of the user eeprom can be done in normal modes. each eeprom byte or aligned word must be erased before programming. the eeprom module supports byte, aligned word, row (32 bytes) or bulk erase, all using the internal charge pump. the erased state is $ff. the eeprom module has hardware interlocks which protect stored data from corruption by accidentally enabling the program/erase voltage. programming voltage is derived from the internal v dd supply with an internal charge pump. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 428 appendix: mc68hc912dg128a eeprom motorola 22.3 eeprom programmer ? s model the eeprom module consists of two separately addressable sections. the first is an eight-byte memory mapped control register block used for control, testing and configuration of the eeprom array. the second section is the eeprom array itself. at reset, the eight-byte register section starts at address $00ec and the eeprom array is located from addresses $0800 to $0fff. registers $00ec-$00ed are reserved. read/write access to the memory array section can be enabled or disabled by the eeon control bit in the initee register ($0012). this feature allows the access of memory mapped resources that have lower priority than the eeprom memory array. eeprom control registers can be accessed regardless of the state of eeon. for information on re- mapping the register block and eeprom address space, refer to operating modes . caution: it is strongly recommended to discontinue program/erase operations during wait (when eeswai=1) or stop modes since all program/erase activities will be terminated abruptly and considered unsuccessful. for lowest power consumption during wait mode, it is advised to turn off eepgm. the eeprom module contains an extra word called shadow word which is loaded at reset into the eemcr, eedivh and eedivl registers. to program the shadow word, when in special modes (smodn=0), the noshw bit in eemcr register must be cleared. normal programming routines are used to program the shadow word which becomes accessible at address $0fc0 ? $0fc1 when noshw is cleared. at the next reset the shadow word data is loaded into the eemcr, eedivh and eedivl registers. the shadow word can be protected from being programmed or erased by setting the shprot bit of eeprot register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom eeprom programmer ? s model mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 429 a steady internal self-time clock is required to provide accurate counts to meet eeprom program/erase requirements. this clock is generated via by a programmable 10-bit prescaler register. automatic program/erase termination is also provided. in ordinary situations, with crystal operating properly, the steady internal self-time clock is derived from the input clock source (extali). the divider value is as in eedivh:eedivl. in limp-home mode, where the oscillator has malfunctioned or is unavailable, the self-time clock is derived from the pll with approximately 1 mhz frequency, with a predefined divider value of $0023. program/erase operation is not guaranteed in limp-home mode. the clock switching function is only applicable for permanent loss of crystal condition, so the program/erase will also not be guaranteed when the loss of crystal condition is intermittent. it is strongly recommended that the clock monitor is enabled to ensure that the program/erase operation will be shutdown in the event of loss of crystal with a clock monitor reset, or switch to a limp-home mode clock. this will prevent unnecessary stress on the emulated eeprom during oscillator failure. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 430 appendix: mc68hc912dg128a eeprom motorola 22.4 eeprom control registers eediv[9:0] ? prescaler divider loaded from shadow word at reset. read anytime. write once in normal modes (smodn =1) if eelat = 0 and anytime in special modes (smodn =0) if eelat = 0. the prescaler divider is required to produce a self-time clock with a fixed frequency around 28.6 khz for the range of oscillator frequencies. the divider is set so that the oscillator frequency can be divided by a divide factor that can produce a 35 ?? ? ???????????? ????????? ????????? ?? ????????? ??????????? ??????? ? ? eeprom modulus divider $00ee bit 7654321bit 0 000000eediv9eediv8 reset: 0 0 0 0 0 0 ? (1) ? (1) 1. loaded from shadow word. eedivl ? eeprom modulus divider $00ef bit 7654321bit 0 eediv7 eediv6 eediv5 eediv4 eediv3 eediv2 eediv1 eediv0 reset: ? (1) ? (1) ? (1) ? (1) ? (1) ? (1) ? (1) ? (1) 1. loaded from shadow word. eediv int extali (hz) x 35 6 ? [] f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom eeprom control registers mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 431 bits[7:4] are loaded at reset from the eeprom shadow word. note: the bits 5 and 4 are reserved for test purposes. these locations in shadow word should not be programmed otherwise some locations of regular eeprom array will not be more visible. nobdml ? background debug mode lockout disable 0 = the bdm lockout is enabled. 1 = the bdm lockout is disabled. loaded from shadow word at reset. read anytime. write anytime in special modes (smodn=0). noshw ? shadow word disable 0 = the shadow word is enabled and accessible at address $0fc0-$0fc1. 1 = regular eeprom array at address $0fc0-$0fc1. loaded from shadow word at reset. read anytime. write anytime in special modes (smodn=0). when noshw cleared, the regular eeprom array bytes at address $0fc0 and $0fc1 are not visible. the shadow word is accessed instead for both read and program/erase operations. bits[7:4] from table 22-1. eediv selection osc freq. osc period divide factor eediv 16 mhz 62.5ns 560 $0230 8 mhz 125ns 280 $0118 4 mhz 250ns 140 $008c 2 mhz 500ns 70 $0046 1 mhz 1 [ ? [ ? [ ? ? eeprom module configuration $00f0 bit 7654321bit 0 nobdml noshw reserved (1) 1 eeswai protlck dmy reset: ? (2) ? (2) ? (2) ? (2) 1100 1. bits 4 and 5 have test functions and should not be programmed. 2. loaded from shadow word. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 432 appendix: mc68hc912dg128a eeprom motorola the high byte of the shadow word, $0fc0, are loaded to eemcr[7:4]. bits[1:0] from the high byte of the shadow word, $0fc0,are loaded to eedivh[1:0]. bits[7:0] from the low byte of the shadow word, $0fc1,are loaded to eedivl[7:0]. bulk program/erase only applies if shadow word is enabled. note: bit 6 from high byte of shadow word should not be programmed in order to have the full eeprom array visible. eeswai ? eeprom stops in wait mode 0 = the module is not affected during wait mode 1 = the module ceases to be clocked during wait mode read and write anytime. note: the eeswai bit should be cleared if the wait mode vectors are mapped in the eeprom array. protlck ? block protect write lock 0 = block protect bits and bulk erase protection bit can be written 1 = block protect bits are locked read anytime. write once in normal modes (smodn = 1), set and clear any time in special modes (smodn = 0). dmy ? dummy bit read and write anytime. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom eeprom control registers mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 433 prevents accidental writes to eeprom. read anytime. write anytime if eepgm = 0 and protlck = 0. shprot ? shadow word protection 0 = the shadow word can be programmed and erased. 1 = the shadow word is protected from being programmed and erased. bprot[5:0] ? eeprom block protection 0 = associated eeprom block can be programmed and erased. 1 = associated eeprom block is protected from being programmed and erased. in normal mode, writes to eetst control bits have no effect and always read zero. the eeprom module cannot be placed in test mode inadvertently during normal operation eeprot ? eeprom block protect $00f1 bit 7654321bit 0 shprot 1 bprot5 bprot4 bprot3 bprot2 bprot1 bprot0 reset: 1 1 1 1 1 1 1 1 table 22-2. 2k byte eeprom block protection bit name block protected block size bprot5 $0800 to $0bff 1024 bytes bprot4 $0c00 to $0dff 512 bytes bprot3 $0e00 to $0eff 256 bytes bprot2 $0f00 to $0f7f 128 bytes bprot1 $0f80 to $0fbf 64 bytes bprot0 $0fc0 to $0fff 64 bytes eetst ? eeprom test $00f2 bit 7654321bit 0 0 erevtn 0 0 0 etmsd etmr etmse reset:00000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 434 appendix: mc68hc912dg128a eeprom motorola . bulkp ? bulk erase protection 0 = eeprom can be bulk erased. 1 = eeprom is protected from being bulk or row erased. read anytime. write anytime if eepgm = 0 and protlck = 0. auto ? automatic shutdown of program/erase operation. eepgm is cleared automatically after the program/erase cycles are finished when auto is set. 0 = automatic clear of eepgm is disabled. 1 = automatic clear of eepgm is enabled. read anytime. write anytime if eepgm = 0. byte ? byte and aligned word erase 0 = bulk or row erase is enabled. 1 = one byte or one aligned word erase only. read anytime. write anytime if eepgm = 0. row ? row or bulk erase (when byte = 0) 0 = erase entire eeprom array. 1 = erase only one 32-byte row. read anytime. write anytime if eepgm = 0. byte and row have no effect when erase = 0 eeprog ? eeprom control $00f3 bit 7654321bit 0 bulkp 0 auto byte row erase eelat eepgm reset:10000000 table 22-3. erase selection byte row block size 0 0 bulk erase entire eeprom array 0 1 row erase 32 bytes 1 0 byte or aligned word erase 1 1 byte or aligned word erase f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom eeprom control registers mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 435 if byte = 1 only the location specified by the address written to the programming latches will be erased. the operation will be a byte or an aligned word erase depending on the size of written data. erase ? erase control 0 = eeprom configuration for programming. 1 = eeprom configuration for erasure. read anytime. write anytime if eepgm = 0. configures the eeprom for erasure or programming. unless bulkp is set, erasure is by byte, aligned word, row or bulk. eelat ? eeprom latch control 0 = eeprom set up for normal reads. 1 = eeprom address and data bus latches set up for programming or erasing. read anytime. write anytime except when eepgm = 1 or eediv = 0. byte, row, erase and eelat bits can be written simultaneously or in any sequence. eepgm ? program and erase enable 0 = disables program/erase voltage to eeprom. 1 = applies program/erase voltage to eeprom. the eepgm bit can be set only after eelat has been set. when eelat and eepgm are set simultaneously, eepgm remains clear but eelat is set. the bulkp, auto, byte, row, erase and eelat bits cannot be changed when eepgm is set. to complete a program or erase cycle when auto bit is clear, two successive writes to clear eepgm and eelat bits are required before reading the programmed data. when auto bit is set, eepgm is automatically cleared after the program or erase cycle is over. a write to an eeprom location has no effect when eepgm is set. latched address and data cannot be modified during program or erase. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 436 appendix: mc68hc912dg128a eeprom motorola 22.5 program/erase operation a program or erase operation should follow the sequence below if auto bit is clear: 1. write byte, row and erase to desired value, write eelat = 1 2. write a byte or an aligned word to an eeprom address 3. write eepgm = 1 4. wait for programming, t prog or erase, t erase delay time (10ms) 5. write eepgm = 0 6. write eelat = 0 if auto bit is set, steps 4 and 5 can be replaced by a step to poll the eepgm bit until is cleared. it is possible to program/erase more bytes or words without intermediate eeprom reads, by jumping from step 5 to step 2. 22.6 shadow word mapping the shadow word is mapped to location $_fc0 and $_fc1 when the noshw bit in eemcr register is zero. the value in the shadow word is loaded to the eemcr, eedivh and eedivl after reset. table 22-4 shows the mapping of each bit from shadow word to the registers table 22-4. shadow word mapping shadow word location register / bit $_fc0 bit 7 eemcr / nobdml $_fc0, bit 6 eemcr / noshw $_fc0, bit 5 eemcr / bit 5 (1) 1. reserved for testing. must be set to one in user application. $_fc0, bit 4 eemcr / bit 4 (1) $_fc0, bit 3:2 not mapped (2)) 2. reserved. must be set to one in user application for future compatibility. $_fc0, bit 1:0 eedivh / bit 1:0 $_fc1, bit 7:0 eemcr / bit 7:0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom programming eedivh and eedivl registers mc68hc912dg128 ? rev 3.0 technical data motorola appendix: mc68hc912dg128a eeprom 437 22.7 programming eedivh and eedivl registers the eedivh and eedivl registers must be correctly set according to the oscillator frequency before any eeprom location can be programmed or erased. 22.7.1 normal mode the eedivh and eedivl registers are write once in normal mode. upon system reset, the application program is required to write correct divider value to eedivh and eedivl registers based on the oscillator frequency. after the first write, the value in the eedivh and eedivl registers is locked from been overwritten until the next reset. the eeprom is then ready for standard program/erase routines. caution: runaway code can possibly corrupt the eedivh and eedivl registers if they are not initialized for the write once. 22.7.2 special mode if an existing application code with eeprom program/erase routines is fixed and the system is already operating at a known oscillator frequency, it is recommended to initialize the shadow word with the corresponding eedivh and eedivl values in special mode. the shadow word initializes eedivh and eedivl registers upon system reset to ensure software compatibility with existing code. initializing the eedivh and eedivl registers in special modes (smodn=0) is accomplished by the following steps. 1. write correct divider value to eedivh and eedivl registers based on the oscillator frequency as per table 22-1 . 2. remove the shadow word protection by clearing shprot bit in eeprot register. 3. clear noshw bit in eemcr register to make the shadow word visible at $0fc0-$0fc1. 4. write noshw bit in eemcr register to make the shadow word visible at $0fc0-$0fc1. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
appendix: mc68hc912dg128a eeprom technical data mc68hc912dg128 ? rev 3.0 438 appendix: mc68hc912dg128a eeprom motorola 5. program bits 1 and 0 of the high byte of the shadow word and bits 7 to 0 of the low byte of the shadow word like a regular eeprom location at address $0fc0 and $0fc1. do not program other bits of the high byte of the shadow word (location $0fc0); otherwise some regular eeprom array locations will not be visible. at the next reset, the shadow values are loaded into the eedivh and eedivl registers. they do not require further initialization as long as the oscillator frequency of the target application is not changed. 6. protect the shadow word by setting shprot bit in eeprot register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola revision history 439 technical data ? mc68hc912dg128 section 23. revision history this section lists the revision history of the document since the first release. data for previous versions and internal drafts is unavailable. changes from rev 2.0 to rev 3.0 section page (in rev 3.0) description of change pinout and signal descriptions 41 c a in figure 3-3 changed to c p 43 note added about consideration of crystal selection due to emc emissions clock functions 157 note added about consideration of crystal selection due to emc emissions 161 major rewrite of limp-home and fast stop recovery modes . 179 system clock frequency formulas updated for clarification. 180 figure 11-6 modified for clarification. 183 figure 11-9 modified for clarification. mscan controller 326 first two bullets of sleep mode description updated 339 slprq = 1 description updated electrical specifications 392 changes to maximum eeprom erase and data retention times 395 f xtal removed 395 footnote added restricting external oscillator operating frequency to 8mhz when using a quartz crystal 406 table footnote removed from table 19-16 regarding v ddpll f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
revision history technical data mc68hc912dg128 ? rev 3.0 440 revision history motorola changes from rev 1.0 to rev 2.0 appendix: cgm practical aspects 408 added section on dc bias 409 point 3 removed regarding high frequency resonators 412 in paragraph 2, c changed to c 0 , r changed to r 0 413 in table 20-1 in header, c changed to c 0 , r changed to r 0 extra column added for c p 413 in table 20-2 in header, c changed to c 0 , r changed to r 0 extra column added for c p 417 extra bullets added section page (in rev 2.0) description of change clock functions 157 prescaled mclk and timclk signal names added to figure 21 for clarification ect 188 prescaled clock from timer changed to prescaled mclk in figure 29 for clarification msi 244 sp0dr register state on reset clarified section page (in rev 3.0) description of change f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
mc68hc912dg128 ? rev 3.0 technical data motorola glossary 441 technical data ? mc68hc912dg128 glossary a ? see ? accumulators (a and b or d). ? accumulators (a and b or d) ? two 8-bit (a and b) or one 16-bit (d) general-purpose registers in the cpu. the cpu uses the accumulators to hold operands and results of arithmetic and logic operations. acquisition mode ? a mode of pll operation with large loop bandwidth. also see ? tracking mode ? . address bus ? the set of wires that the cpu or dma uses to read and write memory locations. addressing mode ? the way that the cpu determines the operand address for an instruction. the m68hc12 cpu has 15 addressing modes. alu ? see ? arithmetic logic unit (alu). ? analogue-to-digital converter (atd) ? the atd module is an 8-channel, multiplexed-input successive-approximation analog-to-digital converter. arithmetic logic unit (alu) ? the portion of the cpu that contains the logic circuitry to perform arithmetic, logic, and manipulation operations on operands. asynchronous ? refers to logic circuits and operations that are not synchronized by a common reference signal. atd ? see ? analogue-to-digital converter ? . b ? see ? accumulators (a and b or d). ? baud rate ? the total number of bits transmitted per unit of time. bcd ? see ? binary-coded decimal (bcd). ? binary ? relating to the base 2 number system. binary number system ? the base 2 number system, having two digits, 0 and 1. binary arithmetic is convenient in digital circuit design because digital circuits have two permissible voltage levels, low and high. the binary digits 0 and 1 can be interpreted to correspond to the two digital voltage levels. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary technical data mc68hc912dg128 ? rev 3.0 442 glossary motorola binary-coded decimal (bcd) ? a notation that uses 4-bit binary numbers to represent the 10 decimal digits and that retains the same positional structure of a decimal number. for example, 234 (decimal) = 0010 0011 0100 (bcd) bit ? a binary digit. a bit has a value of either logic 0 or logic 1. branch instruction ? an instruction that causes the cpu to continue processing at a memory location other than the next sequential address. break module ? the break module allows software to halt program execution at a programmable point in order to enter a background routine. breakpoint ? a number written into the break address registers of the break module. when a number appears on the internal address bus that is the same as the number in the break address registers, the cpu executes the software interrupt instruction (swi). break interrupt ? a software interrupt caused by the appearance on the internal address bus of the same value that is written in the break address registers. bus ? a set of wires that transfers logic signals. bus clock ? see "cpu clock". byte ? a set of eight bits. can ? see "motorola scalable can." ccr ? see ? condition code register. ? central processor unit (cpu) ? the primary functioning unit of any computer system. the cpu controls the execution of instructions. cgm ? see ? clock generator module (cgm). ? clear ? to change a bit from logic 1 to logic 0; the opposite of set. clock ? a square wave signal used to synchronize events in a computer. clock generator module (cgm) ? the cgm module generates a base clock signal from which the system clocks are derived. the cgm may include a crystal oscillator circuit and/or phase-locked loop (pll) circuit. comparator ? a device that compares the magnitude of two inputs. a digital comparator defines the equality or relative differences between two binary numbers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary mc68hc912dg128 ? rev 3.0 technical data motorola glossary 443 computer operating properly module (cop) ? a counter module that resets the mcu if allowed to overflow. condition code register (ccr) ? an 8-bit register in the cpu that contains the interrupt mask bit and five bits that indicate the results of the instruction just executed. control bit ? one bit of a register manipulated by software to control the operation of the module. control unit ? one of two major units of the cpu. the control unit contains logic functions that synchronize the machine and direct various operations. the control unit decodes instructions and generates the internal control signals that perform the requested operations. the outputs of the control unit drive the execution unit, which contains the arithmetic logic unit (alu), cpu registers, and bus interface. cop ? see "computer operating properly module (cop)." cpu ? see ? central processor unit (cpu). ? cpu12 ? the cpu of the mc68hc12 family. cpu clock ? bus clock select bits bcsp and bcss in the clock select register (clksel) determine which clock drives sysclk for the main system, including the cpu and buses. when extali drives the sysclk, the cpu or bus clock frequency (f o ) is equal to the extali frequency divided by 2. cpu cycles ? a cpu cycle is one period of the internal bus clock, normally derived by dividing a crystal oscillator source by two or more so the high and low times will be equal. the length of time required to execute an instruction is measured in cpu clock cycles. cpu registers ? memory locations that are wired directly into the cpu logic instead of being part of the addressable memory map. the cpu always has direct access to the information in these registers. the cpu registers in an m68hc12 are:  a (8-bit accumulator)  b (8-bit accumulator) ? d (16-bit accumulator formed by concatenation of accumulators a and b)  ix (16-bit index register)  iy (16-bit index register)  sp (16-bit stack pointer)  pc (16-bit program counter)  ccr (8-bit condition code register) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary technical data mc68hc912dg128 ? rev 3.0 444 glossary motorola cycle time ? the period of the operating frequency: t cyc =1/f op . d ? see ? accumulators (a and b or d). ? decimal number system ? base 10 numbering system that uses the digits zero through nine. duty cycle ? a ratio of the amount of time the signal is on versus the time it is off. duty cycle is usually represented by a percentage. ect ? see ? enhanced capture timer. ? eeprom ? electrically erasable, programmable, read-only memory. a nonvolatile type of memory that can be electrically erased and reprogrammed. eprom ? erasable, programmable, read-only memory. a nonvolatile type of memory that can be erased by exposure to an ultraviolet light source and then reprogrammed. enhanced capture timer (ect) ? the hc12 enhanced capture timer module has the features of the hc12 standard timer module enhanced by additional features in order to enlarge the field of applications. exception ? an event such as an interrupt or a reset that stops the sequential execution of the instructions in the main program. fetch ? to copy data from a memory location into the accumulator. firmware ? instructions and data programmed into nonvolatile memory. free-running counter ? a device that counts from zero to a predetermined number, then rolls over to zero and begins counting again. full-duplex transmission ? communication on a channel in which data can be sent and received simultaneously. hexadecimal ? base 16 numbering system that uses the digits 0 through 9 and the letters a through f. high byte ? the most significant eight bits of a word. illegal address ? an address not within the memory map illegal opcode ? a nonexistent opcode. index registers (ix and iy) ? two 16-bit registers in the cpu. in the indexed addressing modes, the cpu uses the contents of ix or iy to determine the effective address of the operand. ix and iy can also serve as a temporary data storage locations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary mc68hc912dg128 ? rev 3.0 technical data motorola glossary 445 input/output (i/o) ? input/output interfaces between a computer system and the external world. a cpu reads an input to sense the level of an external signal and writes to an output to change the level on an external signal. instructions ? operations that a cpu can perform. instructions are expressed by programmers as assembly language mnemonics. a cpu interprets an opcode and its associated operand(s) and instruction. inter-ic bus (i 2 c) ? a two-wire, bidirectional serial bus that provides a simple, efficient method of data exchange between devices. interrupt ? a temporary break in the sequential execution of a program to respond to signals from peripheral devices by executing a subroutine. interrupt request ? a signal from a peripheral to the cpu intended to cause the cpu to execute a subroutine. i/o ? see ? input/output (i/0). ? jitter ? short-term signal instability. latch ? a circuit that retains the voltage level (logic 1 or logic 0) written to it for as long as power is applied to the circuit. latency ? the time lag between instruction completion and data movement. least significant bit (lsb) ? the rightmost digit of a binary number. logic 1 ? a voltage level approximately equal to the input power voltage (v dd ). logic 0 ? a voltage level approximately equal to the ground voltage (v ss ). low byte ? the least significant eight bits of a word. m68hc12 ? a motorola family of 16-bit mcus. mark/space ? the logic 1/logic 0 convention used in formatting data in serial communication. mask ? 1. a logic circuit that forces a bit or group of bits to a desired state. 2. a photomask used in integrated circuit fabrication to transfer an image onto silicon. mcu ? microcontroller unit. see ? microcontroller. ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary technical data mc68hc912dg128 ? rev 3.0 446 glossary motorola memory location ? each m68hc12 memory location holds one byte of data and has a unique address. to store information in a memory location, the cpu places the address of the location on the address bus, the data information on the data bus, and asserts the write signal. to read information from a memory location, the cpu places the address of the location on the address bus and asserts the read signal. in response to the read signal, the selected memory location places its data onto the data bus. memory map ? a pictorial representation of all memory locations in a computer system. mi-bus ? see "motorola interconnect bus". microcontroller ? microcontroller unit (mcu). a complete computer system, including a cpu, memory, a clock oscillator, and input/output (i/o) on a single integrated circuit. modulo counter ? a counter that can be programmed to count to any number from zero to its maximum possible modulus. most significant bit (msb) ? the leftmost digit of a binary number. motorola interconnect bus (mi-bus) ? the motorola interconnect bus (mi bus) is a serial communications protocol which supports distributed real-time control efficiently and with a high degree of noise immunity. motorola scalable can (mscan) ? the motorola scalable controller area network is a serial communications protocol that efficiently supports distributed real-time control with a very high level of data integrity. mscan ? see "motorola scalable can". msi ? see "multiple serial interface". multiple serial interface ? a module consisting of multiple independent serial i/o sub-systems, e.g. two sci and one spi. multiplexer ? a device that can select one of a number of inputs and pass the logic level of that input on to the output. nibble ? a set of four bits (half of a byte). object code ? the output from an assembler or compiler that is itself executable machine code, or is suitable for processing to produce executable machine code. opcode ? a binary code that instructs the cpu to perform an operation. open-drain ? an output that has no pullup transistor. an external pullup device can be connected to the power supply to provide the logic 1 output voltage. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary mc68hc912dg128 ? rev 3.0 technical data motorola glossary 447 operand ? data on which an operation is performed. usually a statement consists of an operator and an operand. for example, the operator may be an add instruction, and the operand may be the quantity to be added. oscillator ? a circuit that produces a constant frequency square wave that is used by the computer as a timing and sequencing reference. otprom ? one-time programmable read-only memory. a nonvolatile type of memory that cannot be reprogrammed. overflow ? a quantity that is too large to be contained in one byte or one word. page zero ? the first 256 bytes of memory (addresses $0000 ? $00ff). parity ? an error-checking scheme that counts the number of logic 1s in each byte transmitted. in a system that uses odd parity, every byte is expected to have an odd number of logic 1s. in an even parity system, every byte should have an even number of logic 1s. in the transmitter, a parity generator appends an extra bit to each byte to make the number of logic 1s odd for odd parity or even for even parity. a parity checker in the receiver counts the number of logic 1s in each byte. the parity checker generates an error signal if it finds a byte with an incorrect number of logic 1s. pc ? see ? program counter (pc). ? peripheral ? a circuit not under direct cpu control. phase-locked loop (pll) ? a clock generator circuit in which a voltage controlled oscillator produces an oscillation which is synchronized to a reference signal. pll ? see "phase-locked loop (pll)." pointer ? pointer register. an index register is sometimes called a pointer register because its contents are used in the calculation of the address of an operand, and therefore points to the operand. polarity ? the two opposite logic levels, logic 1 and logic 0, which correspond to two different voltage levels, v dd and v ss . polling ? periodically reading a status bit to monitor the condition of a peripheral device. port ? a set of wires for communicating with off-chip devices. prescaler ? a circuit that generates an output signal related to the input signal by a fractional scale factor such as 1/2, 1/8, 1/10 etc. program ? a set of computer instructions that cause a computer to perform a desired operation or operations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary technical data mc68hc912dg128 ? rev 3.0 448 glossary motorola program counter (pc) ? a 16-bit register in the cpu. the pc register holds the address of the next instruction or operand that the cpu will use. pull ? an instruction that copies into the accumulator the contents of a stack ram location. the stack ram address is in the stack pointer. pullup ? a transistor in the output of a logic gate that connects the output to the logic 1 voltage of the power supply. pulse-width ? the amount of time a signal is on as opposed to being in its off state. pulse-width modulation (pwm) ? controlled variation (modulation) of the pulse width of a signal with a constant frequency. push ? an instruction that copies the contents of the accumulator to the stack ram. the stack ram address is in the stack pointer. pwm period ? the time required for one complete cycle of a pwm waveform. ram ? random access memory. all ram locations can be read or written by the cpu. the contents of a ram memory location remain valid until the cpu writes a different value or until power is turned off. rc circuit ? a circuit consisting of capacitors and resistors having a defined time constant. read ? to copy the contents of a memory location to the accumulator. register ? a circuit that stores a group of bits. reserved memory location ? a memory location that is used only in special factory test modes. writing to a reserved location has no effect. reading a reserved location returns an unpredictable value. reset ? to force a device to a known condition. sci ? see "serial communication interface module (sci)." serial ? pertaining to sequential transmission over a single line. serial communications interface module (sci) ? a module that supports asynchronous communication. serial peripheral interface module (spi) ? a module that supports synchronous communication. set ? to change a bit from logic 0 to logic 1; opposite of clear. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary mc68hc912dg128 ? rev 3.0 technical data motorola glossary 449 shift register ? a chain of circuits that can retain the logic levels (logic 1 or logic 0) written to them and that can shift the logic levels to the right or left through adjacent circuits in the chain. signed ? a binary number notation that accommodates both positive and negative numbers. the most significant bit is used to indicate whether the number is positive or negative, normally logic 0 for positive and logic 1 for negative. the other seven bits indicate the magnitude of the number. software ? instructions and data that control the operation of a microcontroller. software interrupt (swi) ? an instruction that causes an interrupt and its associated vector fetch. spi ? see "serial peripheral interface module (spi)." stack ? a portion of ram reserved for storage of cpu register contents and subroutine return addresses. stack pointer (sp) ? a 16-bit register in the cpu containing the address of the next available storage location on the stack. start bit ? a bit that signals the beginning of an asynchronous serial transmission. status bit ? a register bit that indicates the condition of a device. stop bit ? a bit that signals the end of an asynchronous serial transmission. subroutine ? a sequence of instructions to be used more than once in the course of a program. the last instruction in a subroutine is a return from subroutine (rts) instruction. at each place in the main program where the subroutine instructions are needed, a jump or branch to subroutine (jsr or bsr) instruction is used to call the subroutine. the cpu leaves the flow of the main program to execute the instructions in the subroutine. when the rts instruction is executed, the cpu returns to the main program where it left off. synchronous ? refers to logic circuits and operations that are synchronized by a common reference signal. timer ? a module used to relate events in a system to a point in time. toggle ? to change the state of an output from a logic 0 to a logic 1 or from a logic 1 to a logic 0. tracking mode ? a mode of pll operation with narrow loop bandwidth. also see ? acquisition mode. ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
glossary technical data mc68hc912dg128 ? rev 3.0 450 glossary motorola two ? s complement ? a means of performing binary subtraction using addition techniques. the most significant bit of a two ? s complement number indicates the sign of the number (1 indicates negative). the two ? s complement negative of a number is obtained by inverting each bit in the number and then adding 1 to the result. unbuffered ? utilizes only one register for data; new data overwrites current data. unimplemented memory location ? a memory location that is not used. writing to an unimplemented location has no effect. reading an unimplemented location returns an unpredictable value. variable ? a value that changes during the course of program execution. vco ? see "voltage-controlled oscillator." vector ? a memory location that contains the address of the beginning of a subroutine written to service an interrupt or reset. voltage-controlled oscillator (vco) ? a circuit that produces an oscillating output signal of a frequency that is controlled by a dc voltage applied to a control input. waveform ? a graphical representation in which the amplitude of a wave is plotted against time. wired-or ? connection of circuit outputs so that if any output is high, the connection point is high. word ? a set of two bytes (16 bits). write ? the transfer of a byte of data from the cpu to a memory location. . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
how to reach us: usa/europe/locations not listed: motorola literature distribution; p.o. box 5405, denver, colorado 80217 1-303-675-2140 or 1-800-441-2447 japan: motorola japan ltd.; sps, technical information center, 3-20-1, minami-azabu minato-ku, tokyo 106-8573 japan 81-3-3440-3569 asia/pacific: motorola semiconductors h.k. ltd.; silicon harbour centre, 2 dai king street, tai po industrial estate, tai po, n.t., hong kong 852-26668334 technical information center: 1-800-521-6274 home page: http://motorola.com/semiconductors information in this document is provided solely to enable system and software implementers to use motorola products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. motorola reserves the right to make changes without further notice to any products herein. motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. ? typical ? parameters which may be provided in motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. all operating parameters, including ? typicals ? must be validated for each customer application by customer ? s technical experts. motorola does not convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola and the stylized m logo are registered in the u.s. patent and trademark office. digital dna is a trademark of motorola, inc. all other product or service names are the property of their respective owners. motorola, inc. is an equal opportunity/affirmative action employer. ? motorola, inc. 2002 mc68hc912dg128/d f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .


▲Up To Search▲   

 
Price & Availability of 68HC912DG128CPV8

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X